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?

已提问 2 年前846 查看次数
2 回答
1
已接受的回答

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
专家
Toni_S
已回答 2 年前
  • 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
支持工程师
Ansh_C
已回答 2 年前
  • 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.

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

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

回答问题的准则