ssh Connection refused, stuck at “debug1: Local version string”

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm trying to connect to my Redhat AWS instance with a port other than 22.



This command works:
ssh -i my.pem -p 22 ec2-user@X.X.X.X

But this command does not:ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X



The second command outputs:



OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to X.X.X.X port 8157.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file my.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file my.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6


but then just hangs. On the server I'm trying to connect to, however, when I run nc -l 8157 I can see



SSH-2.0-OpenSSH_7.6


If I take out the -vvv part I just get a quick "Connection refused" error.



When I log into the machine and run ssh -p 8157 -vvv ec2-user@localhost



I get the following output:



OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "localhost" port 8157
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 8157.
debug1: connect to address 127.0.0.1 port 8157: Connection refused
ssh: connect to host localhost port 8157: Connection refused


Any idea what's going on?







share|improve this question






















  • Have you opened up the firewall or changed the AWS security policies to allow access to that port?
    – GracefulRestart
    Mar 22 at 23:24










  • If you login to the AWS system and then run ssh ... ec2-user@localhost , does that work?
    – Mark Plotnick
    Mar 22 at 23:24










  • @GracefulRestart Yes, I've opened up the security group on the instance. I've also checked the VPC flow logs and I can see my source and target IP and the 8157 port showing up as "ACCEPT OK", so I don't think it's an AWS firewall issue. Also, if the security group were the issue I wouldn't be able to establish a connect at all, right? The ssh verbose command says Connection established, so I think it's getting through, it's just not finishing.
    – user554481
    Mar 22 at 23:35










  • @MarkPlotnick What could go in the . . .? I didn't know you could connect to localhost. I'm guessing I would just do ssh -p 8157 ec2-user@localhost?
    – user554481
    Mar 22 at 23:37










  • Same command - ssh -i my.pem -p 8157 -vvv ec2-user@localhost . This will remove from consideration all (or all but one) firewalls.
    – Mark Plotnick
    Mar 23 at 0:00














up vote
0
down vote

favorite












I'm trying to connect to my Redhat AWS instance with a port other than 22.



This command works:
ssh -i my.pem -p 22 ec2-user@X.X.X.X

But this command does not:ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X



The second command outputs:



OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to X.X.X.X port 8157.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file my.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file my.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6


but then just hangs. On the server I'm trying to connect to, however, when I run nc -l 8157 I can see



SSH-2.0-OpenSSH_7.6


If I take out the -vvv part I just get a quick "Connection refused" error.



When I log into the machine and run ssh -p 8157 -vvv ec2-user@localhost



I get the following output:



OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "localhost" port 8157
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 8157.
debug1: connect to address 127.0.0.1 port 8157: Connection refused
ssh: connect to host localhost port 8157: Connection refused


Any idea what's going on?







share|improve this question






















  • Have you opened up the firewall or changed the AWS security policies to allow access to that port?
    – GracefulRestart
    Mar 22 at 23:24










  • If you login to the AWS system and then run ssh ... ec2-user@localhost , does that work?
    – Mark Plotnick
    Mar 22 at 23:24










  • @GracefulRestart Yes, I've opened up the security group on the instance. I've also checked the VPC flow logs and I can see my source and target IP and the 8157 port showing up as "ACCEPT OK", so I don't think it's an AWS firewall issue. Also, if the security group were the issue I wouldn't be able to establish a connect at all, right? The ssh verbose command says Connection established, so I think it's getting through, it's just not finishing.
    – user554481
    Mar 22 at 23:35










  • @MarkPlotnick What could go in the . . .? I didn't know you could connect to localhost. I'm guessing I would just do ssh -p 8157 ec2-user@localhost?
    – user554481
    Mar 22 at 23:37










  • Same command - ssh -i my.pem -p 8157 -vvv ec2-user@localhost . This will remove from consideration all (or all but one) firewalls.
    – Mark Plotnick
    Mar 23 at 0:00












up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm trying to connect to my Redhat AWS instance with a port other than 22.



This command works:
ssh -i my.pem -p 22 ec2-user@X.X.X.X

But this command does not:ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X



The second command outputs:



OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to X.X.X.X port 8157.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file my.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file my.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6


but then just hangs. On the server I'm trying to connect to, however, when I run nc -l 8157 I can see



SSH-2.0-OpenSSH_7.6


If I take out the -vvv part I just get a quick "Connection refused" error.



When I log into the machine and run ssh -p 8157 -vvv ec2-user@localhost



I get the following output:



OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "localhost" port 8157
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 8157.
debug1: connect to address 127.0.0.1 port 8157: Connection refused
ssh: connect to host localhost port 8157: Connection refused


Any idea what's going on?







share|improve this question














I'm trying to connect to my Redhat AWS instance with a port other than 22.



This command works:
ssh -i my.pem -p 22 ec2-user@X.X.X.X

But this command does not:ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X



The second command outputs:



OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to X.X.X.X port 8157.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file my.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file my.pem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6


but then just hangs. On the server I'm trying to connect to, however, when I run nc -l 8157 I can see



SSH-2.0-OpenSSH_7.6


If I take out the -vvv part I just get a quick "Connection refused" error.



When I log into the machine and run ssh -p 8157 -vvv ec2-user@localhost



I get the following output:



OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug2: resolving "localhost" port 8157
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 8157.
debug1: connect to address 127.0.0.1 port 8157: Connection refused
ssh: connect to host localhost port 8157: Connection refused


Any idea what's going on?









share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 14:48









Vlastimil

6,3661146117




6,3661146117










asked Mar 22 at 23:11









user554481

1035




1035











  • Have you opened up the firewall or changed the AWS security policies to allow access to that port?
    – GracefulRestart
    Mar 22 at 23:24










  • If you login to the AWS system and then run ssh ... ec2-user@localhost , does that work?
    – Mark Plotnick
    Mar 22 at 23:24










  • @GracefulRestart Yes, I've opened up the security group on the instance. I've also checked the VPC flow logs and I can see my source and target IP and the 8157 port showing up as "ACCEPT OK", so I don't think it's an AWS firewall issue. Also, if the security group were the issue I wouldn't be able to establish a connect at all, right? The ssh verbose command says Connection established, so I think it's getting through, it's just not finishing.
    – user554481
    Mar 22 at 23:35










  • @MarkPlotnick What could go in the . . .? I didn't know you could connect to localhost. I'm guessing I would just do ssh -p 8157 ec2-user@localhost?
    – user554481
    Mar 22 at 23:37










  • Same command - ssh -i my.pem -p 8157 -vvv ec2-user@localhost . This will remove from consideration all (or all but one) firewalls.
    – Mark Plotnick
    Mar 23 at 0:00
















  • Have you opened up the firewall or changed the AWS security policies to allow access to that port?
    – GracefulRestart
    Mar 22 at 23:24










  • If you login to the AWS system and then run ssh ... ec2-user@localhost , does that work?
    – Mark Plotnick
    Mar 22 at 23:24










  • @GracefulRestart Yes, I've opened up the security group on the instance. I've also checked the VPC flow logs and I can see my source and target IP and the 8157 port showing up as "ACCEPT OK", so I don't think it's an AWS firewall issue. Also, if the security group were the issue I wouldn't be able to establish a connect at all, right? The ssh verbose command says Connection established, so I think it's getting through, it's just not finishing.
    – user554481
    Mar 22 at 23:35










  • @MarkPlotnick What could go in the . . .? I didn't know you could connect to localhost. I'm guessing I would just do ssh -p 8157 ec2-user@localhost?
    – user554481
    Mar 22 at 23:37










  • Same command - ssh -i my.pem -p 8157 -vvv ec2-user@localhost . This will remove from consideration all (or all but one) firewalls.
    – Mark Plotnick
    Mar 23 at 0:00















Have you opened up the firewall or changed the AWS security policies to allow access to that port?
– GracefulRestart
Mar 22 at 23:24




Have you opened up the firewall or changed the AWS security policies to allow access to that port?
– GracefulRestart
Mar 22 at 23:24












If you login to the AWS system and then run ssh ... ec2-user@localhost , does that work?
– Mark Plotnick
Mar 22 at 23:24




If you login to the AWS system and then run ssh ... ec2-user@localhost , does that work?
– Mark Plotnick
Mar 22 at 23:24












@GracefulRestart Yes, I've opened up the security group on the instance. I've also checked the VPC flow logs and I can see my source and target IP and the 8157 port showing up as "ACCEPT OK", so I don't think it's an AWS firewall issue. Also, if the security group were the issue I wouldn't be able to establish a connect at all, right? The ssh verbose command says Connection established, so I think it's getting through, it's just not finishing.
– user554481
Mar 22 at 23:35




@GracefulRestart Yes, I've opened up the security group on the instance. I've also checked the VPC flow logs and I can see my source and target IP and the 8157 port showing up as "ACCEPT OK", so I don't think it's an AWS firewall issue. Also, if the security group were the issue I wouldn't be able to establish a connect at all, right? The ssh verbose command says Connection established, so I think it's getting through, it's just not finishing.
– user554481
Mar 22 at 23:35












@MarkPlotnick What could go in the . . .? I didn't know you could connect to localhost. I'm guessing I would just do ssh -p 8157 ec2-user@localhost?
– user554481
Mar 22 at 23:37




@MarkPlotnick What could go in the . . .? I didn't know you could connect to localhost. I'm guessing I would just do ssh -p 8157 ec2-user@localhost?
– user554481
Mar 22 at 23:37












Same command - ssh -i my.pem -p 8157 -vvv ec2-user@localhost . This will remove from consideration all (or all but one) firewalls.
– Mark Plotnick
Mar 23 at 0:00




Same command - ssh -i my.pem -p 8157 -vvv ec2-user@localhost . This will remove from consideration all (or all but one) firewalls.
– Mark Plotnick
Mar 23 at 0:00










1 Answer
1






active

oldest

votes

















up vote
1
down vote



accepted











This command works: ssh -i my.pem -p 22 ec2-user@X.X.X.X



But this command does not: ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X





Your other side may have opened port in the firewall, but...



Since port 22 works, your server listens on that port.



Re-configure your server to listen on whatever port you wish.




You can do that in the file:



/etc/ssh/sshd_config


With the following setting:



Port 8157


Don't forget to restart your SSH daemon afterwards.






share|improve this answer






















  • What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
    – user554481
    Mar 23 at 14:45










  • @user554481 Suffice that edit?
    – Vlastimil
    Mar 23 at 14:46










  • Wow, that worked! Is it not open to all ports by default?
    – user554481
    Mar 23 at 14:54










  • @user554481 No, it is not..
    – Vlastimil
    Mar 23 at 14:55











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432962%2fssh-connection-refused-stuck-at-debug1-local-version-string%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote



accepted











This command works: ssh -i my.pem -p 22 ec2-user@X.X.X.X



But this command does not: ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X





Your other side may have opened port in the firewall, but...



Since port 22 works, your server listens on that port.



Re-configure your server to listen on whatever port you wish.




You can do that in the file:



/etc/ssh/sshd_config


With the following setting:



Port 8157


Don't forget to restart your SSH daemon afterwards.






share|improve this answer






















  • What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
    – user554481
    Mar 23 at 14:45










  • @user554481 Suffice that edit?
    – Vlastimil
    Mar 23 at 14:46










  • Wow, that worked! Is it not open to all ports by default?
    – user554481
    Mar 23 at 14:54










  • @user554481 No, it is not..
    – Vlastimil
    Mar 23 at 14:55















up vote
1
down vote



accepted











This command works: ssh -i my.pem -p 22 ec2-user@X.X.X.X



But this command does not: ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X





Your other side may have opened port in the firewall, but...



Since port 22 works, your server listens on that port.



Re-configure your server to listen on whatever port you wish.




You can do that in the file:



/etc/ssh/sshd_config


With the following setting:



Port 8157


Don't forget to restart your SSH daemon afterwards.






share|improve this answer






















  • What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
    – user554481
    Mar 23 at 14:45










  • @user554481 Suffice that edit?
    – Vlastimil
    Mar 23 at 14:46










  • Wow, that worked! Is it not open to all ports by default?
    – user554481
    Mar 23 at 14:54










  • @user554481 No, it is not..
    – Vlastimil
    Mar 23 at 14:55













up vote
1
down vote



accepted







up vote
1
down vote



accepted







This command works: ssh -i my.pem -p 22 ec2-user@X.X.X.X



But this command does not: ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X





Your other side may have opened port in the firewall, but...



Since port 22 works, your server listens on that port.



Re-configure your server to listen on whatever port you wish.




You can do that in the file:



/etc/ssh/sshd_config


With the following setting:



Port 8157


Don't forget to restart your SSH daemon afterwards.






share|improve this answer















This command works: ssh -i my.pem -p 22 ec2-user@X.X.X.X



But this command does not: ssh -i my.pem -p 8157 -vvv ec2-user@X.X.X.X





Your other side may have opened port in the firewall, but...



Since port 22 works, your server listens on that port.



Re-configure your server to listen on whatever port you wish.




You can do that in the file:



/etc/ssh/sshd_config


With the following setting:



Port 8157


Don't forget to restart your SSH daemon afterwards.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 23 at 14:46

























answered Mar 23 at 14:41









Vlastimil

6,3661146117




6,3661146117











  • What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
    – user554481
    Mar 23 at 14:45










  • @user554481 Suffice that edit?
    – Vlastimil
    Mar 23 at 14:46










  • Wow, that worked! Is it not open to all ports by default?
    – user554481
    Mar 23 at 14:54










  • @user554481 No, it is not..
    – Vlastimil
    Mar 23 at 14:55

















  • What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
    – user554481
    Mar 23 at 14:45










  • @user554481 Suffice that edit?
    – Vlastimil
    Mar 23 at 14:46










  • Wow, that worked! Is it not open to all ports by default?
    – user554481
    Mar 23 at 14:54










  • @user554481 No, it is not..
    – Vlastimil
    Mar 23 at 14:55
















What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
– user554481
Mar 23 at 14:45




What do you mean by "Re-configure your server to listen on whatever port you wish." Do you mean change the firewall? My AWS security groups (firewall) are completely open. Are you referring to the ssh daemon's ports? If so, how can I change that?
– user554481
Mar 23 at 14:45












@user554481 Suffice that edit?
– Vlastimil
Mar 23 at 14:46




@user554481 Suffice that edit?
– Vlastimil
Mar 23 at 14:46












Wow, that worked! Is it not open to all ports by default?
– user554481
Mar 23 at 14:54




Wow, that worked! Is it not open to all ports by default?
– user554481
Mar 23 at 14:54












@user554481 No, it is not..
– Vlastimil
Mar 23 at 14:55





@user554481 No, it is not..
– Vlastimil
Mar 23 at 14:55













 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432962%2fssh-connection-refused-stuck-at-debug1-local-version-string%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay