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 個月前檢視次數 1943 次
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 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南