Unable to connect to AWS instance on port 22
We were able to ssh to the EC2 instance using the connect details until today; when it stopped working and I get the below error:
root@DKERP:~# ssh -i "gindustries.pem" [email protected]
ssh: connect to host ec2-15-184-231-34.me-south-1.compute.amazonaws.com port 22: Connection timed out
Also, the telnet to public IP & port 22 is not working
root@DKERP:~# telnet 15.184.231.34 22
Trying 15.184.231.34...
telnet: Unable to connect to remote host: Connection timed out
The session manager is also failing to connect with the below error:
We weren't able to connect to your instance. Common reasons for this include:
SSM Agent isn't installed on the instance. You can install the agent on both Windows instances and Linux instances.
The required IAM instance profile isn't attached to the instance. You can attach a profile using AWS Systems Manager Quick Setup.
Session Manager setup is incomplete. For more information, see Session Manager Prerequisites.
There are no firewalls in AWS configurations.
Overview: Security Groups: Instances: Network Interface: VPC: Network ACLs:
The system logs are updated here: https://pastebin.com/RhAG5DzP
Kindly suggest.
Solution 1:
The Connection timed out
message normally indicates that there is no network connectivity.
In most cases, this is due to the Security Group.
The steps to check it are:
- Select the instance in the Amazon EC2 management console
- Go to the Security tab
- Check the Inbound rules
To permit an SSH connection, there needs to be a rule that permits port 22 (SSH) and the source set to your IP address or from the whole Internet (0.0.0.0/0
) -- preferably only your IP address so that everybody else will be blocked.
When launching an Amazon EC2 instance from the console, it will default to creating a new Security Group called launch-wizard
. However, it is generally better to create your own Security Group with a useful name and only the rules you want. You can then re-use that Security Group in future for similar instances.