SSH connection timeout

0

Hi.. I am unable to ssh into my instance to make some php.ini setting changes. I get connection timeout. Here is what I have done:

  • I am on a Macbook running BigSur 11.6
  • I fully opened up SSH port 22 in Security Groups
  • Instance type is t2.micro
  • I have a public IP
  • I checked that no firewall is blocking.
  • I tried all the different usernames ubuntu, ec2-user, root.
  • Keyfile has been chmod 400'd.
  • My latest instance ID is i-0abb14d7fc4673fb1
  • ssh command with ip zero'd out below: ssh -i "mypem.pem" root@ec2-0-0-0-0.us-east-2.compute.amazonaws.com

I have been chasing google fixes for two days now with no avail. Thanks

  • Can you run the ssh command with the '-v' to see if the debugging information would give a clue?

asked 2 years ago819 views
2 Answers
1
Accepted Answer

Connection timeout is typically related to end to end network connectivity issue and not to username or file permission. Have you followed the Knowledge Article guideline at: https://aws.amazon.com/premiumsupport/knowledge-center/ec2-linux-resolve-ssh-connection-errors/

Also do check that the subnet you deployed this EC2 instance into has route to Internet.

You can also try out the Session Manager instead of SSH connection as way to launch a secure connection into your Instance. Check out more here: https://aws.amazon.com/blogs/aws/new-session-manager/

profile pictureAWS
EXPERT
Toni_S
answered 2 years ago
  • Your second paragraph provided the answer. The subnet deployed to the EC2 instance did not have a route to the internet... I have been poking this so long now that I was surprised to see it finally connect.

0

Hi ! Thanks for using AWS re:Post and providing a brief description of the issue.

It seems that you have tried all the necessary steps for diagnosing the issue . I would suggest having a look at the Route table for the instance and making sure it has an internet gateway attached to it as you are trying to SSH to an instance using its public IP over the internet. Hence, the instance needs to be launched in a public subnet with an internet gateway in its route table (and not NAT gw) . If you need further help, Try opening a ticket with AWS support for their insights as well .

Reference :

[] Troubleshoot connecting to your instance - Error connecting to your instance: Connection timed out - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html#TroubleshootingInstancesConnectionTimeout

AWS
SUPPORT ENGINEER
Ansh_C
answered 2 years ago
  • I checked the internet gateway.. but missed the "subnet with internet gateway" part... After rereading this, I see that your answer is also correct.. Thank you.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions