0
votes

Cannot SSH to ec2 instance. I tested with Ubuntu and Amazon linux. I created the security group but the ssh connection timed out. What could be the possible reason?

enter image description here

1
Is your instance in public subnet? Does it have public IP? Have you modified default NACLs?Marcin
its in default vpc and public subnet. It has a public IP assignedJohn
What about if you try browser based ssh for Amazon Linux2.Marcin
Have these instances previously worked? Do you have any other instances in the same subnet that work?John Rotenstein

1 Answers

1
votes

The standard items to check are:

  • Instance is running Linux (Yes)
  • Instance is in a public subnet (defined as a subnet with a Route Table pointing to an Internet Gateway)
  • Network ACLs have not been changed from their default "Allow All" settings
  • Security Group permits inbound access from your IP address, or 0.0.0.0/0

If it is still not working, then try to access the instance from another network (eg office vs home vs tethered via your phone). Some corporate networks block SSH access.

You could also attempt to access via EC2 Instance Connect or AWS Systems Manager Session Manager (extra permissions required in the IAM Role assigned to the instance).