AWS EC2 Connection (SSH) says – Connection refused

huangapple go评论65阅读模式
英文:

AWS EC2 Connection (SSH) says - Connection refused

问题

I was just connected to the instance over ssh and Change permission on home directory to 755 using "sudo chmod -R 755 .". After that, I can't execute any single commands through SSH shell. So I have disconnect and find my ec2 public IP has been changed. Now i am trying to connect with ec2 instance using .pem file, it says connection refused and port 22 is showing as closed.

Note: I have tried to reconfigure security group inbound rule for port 22 and stop,start my instance but none of these worked.

英文:

I was just connected to the instance over ssh and Change permission on home directory to 755 using "sudo chmod -R 755 ./". After that, I can't execute any single commands through SSH shell. So I have disconnect and find my ec2 public IP has been changed. Now i am trying to connect with ec2 instance using .pem file, it says connection refused and port 22 is showing as closed.

Note: I have tried to reconfigure security group inbound rule for port 22 and stop,start my instance but none of these worked.

答案1

得分: 1

这可能意味着您的EC2实例上的sshd已经停止。

第一件事:SSH对权限非常敏感;请参考ssh-and-home-directory-permissions

第二件事:公共IP的更改意味着实例已经停止/启动,而不仅仅是断开连接;EC2不会在未经停止/启动的情况下失去其公共IP。

因此,您可能在更改权限时破坏了SSH访问权限;而且SSH可能没有启用,所以当您重新启动实例时,它没有启动,导致连接被拒绝错误。

您可以尝试通过控制台连接并进行故障排除;或者遵循此问题的解决方案:https://stackoverflow.com/questions/12447438/ec2-ssh-port-22-connection-refused-even-though-previously-worked?rq=2

英文:

That probably means sshd is down on your ec2 instance.

1st thing: SSH is very sensitive to permissions; please refer to ssh-and-home-directory-permissions

2nd thing: change of public IP means the instance was stopped/started, not just disconnected; an EC2 does not lose its public IP without a stop/start.

So probably you broke your ssh access when changed permissions; and ssh might not have been enabled, so when you reboot the box, it was not started leading to connection refused error.

You can try to connect through the console and troubleshoot; or follow this question https://stackoverflow.com/questions/12447438/ec2-ssh-port-22-connection-refused-even-though-previously-worked?rq=2

huangapple
  • 本文由 发表于 2023年5月29日 15:32:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76355435.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定