port 22: Connection refused

0

I'm trying to connect the ec2-machine with ssh through moba but got the error as port 22: Connection refused. Also trying to connect the same ec2 using putty but got the same error as Network Error : Connection refused.

Rahul
已提问 8 个月前1941 查看次数
3 回答
1

Check all these things:

  • the EC2 has a public IP address
  • the EC2 is in a public-facing subnet - that is a subnet which has an entry in its route table to an Internet Gateway
  • the presence of a security group associated with the EC2 allowing inbound access on TCP port 22
  • the absence of a network ACL associated with the subnet that denies inbound access on TCP port 22

More troubleshooting steps, explained in much greater depth, are here https://repost.aws/knowledge-center/ec2-linux-resolve-ssh-connection-errors

profile picture
专家
Steve_M
已回答 8 个月前
profile picture
专家
已审核 8 个月前
0

Connection refused generally means you don't have the correct security groups configured. Look into your security groups for Inbound Traffic Rules and configure your ip to access on port 22. That should work.

已回答 8 个月前
  • I'm trying this as well but issue was not resolved.

0

'Connection Refused' comes remotely from a host. The following are common causes for this error:

  • The host reached the instance but there was no service listening on the SSH port.
  • A firewall blocked and was set to reject the package instead of dropping it.

Performed a telnet and nmap test on your public IP.

Please follow the troubleshooting steps mentioned in the below article in order to resolve this issue. Please go through this is detail. [+] https://repost.aws/knowledge-center/ec2-linux-resolve-ssh-connection-errors

If you do not have EC2 serial console or AWS systems manager configured/enabled on your instance, you may go ahead with 'Method-4' which is using a user-data script.

The listed user-data script clears all the firewall rules and restarts the ssh service on the instance.

IMPORTANT NOTE: 'Method-4' involves stopping and starting your instance which will change the public IP associated with it. In case you do not want that to happen you can allocate an elastic IP to your instance first. For more info on the same, please refer below. [+] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html

I would also recommend you to take an AMI backup of the instance before making any changes to it -

[+] https://docs.aws.amazon.com/toolkit-for-visual-studio/latest/user-guide/tkv-create-ami-from-instance.html

AWS
支持工程师
已回答 8 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则