- Newest
- Most votes
- Most comments
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
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.
'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 -
Relevant content
- asked a year ago
- asked a year ago
- asked a year ago
- asked 4 years ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated a year ago
I'm trying this as well but issue was not resolved.