Trying to connect to EC2 instance via SSH - intermittently timing out

0

Hi,

I'm trying to connect to an EC2 instance via SSH but I'm getting repeated "Operation timed out" errors when I do so - wondering if anyone can help?

The command

nc -vz <public IP>.compute-1.amazonaws.com 22 gives me nc: connectx to <public IP>.compute-1.amazonaws.com port 22 (tcp) failed: Operation timed out.

I've confirmed that (as far as I can tell) my security group and NACLs are configured properly, and I'm not running any firewalls.

I'm attempting to run on a g4dn.2xl instance with the following AMI (if it's relevant):

Deep Learning AMI GPU PyTorch 2.0.1 (Amazon Linux 2) 20230627 ami-051619310404cab17

Finally - if I run a normal t1.micro instance I don't seem to have any trouble connecting.

Any help would be very much appreciated!

asked 4 months ago474 views
1 Answer
0

Hello, I have a few questions/items to check to help you access your instance via SSH. First off, are you deploying this instance in your default VPC? Or in a VPC that you manually created? Also, does your instance have a public IP?

If you're using a VPC that you manually created, you'll need to create and attach an internet gateway, configure subnets, route tables, and NACLs. If you're using the default VPC, that is already taken care of for you. Regardless of which VPC option you're using, here are some things to check:

  • Security Group Rules: Ensure that your security group has an inbound rule that allows SSH traffic (port 22) from your IP address or the IP range you are connecting from. If you're connecting from a dynamic IP address, you can allow SSH access from 0.0.0.0/0 (anywhere), but allowing SSH access from anywhere is not recommended for production environments.
  • Network ACL (NACL) Rules: The default VPC's NACL allows all traffic by default, but if it's a custom VPC that you created, you'll need to configure the NACL appropriately to allow inbound/outbound traffic. Unlike security groups, NACLs are stateless, which means you'll need to configure both inbound and outbound traffic rules in order for your connection to be successful.
  • Check Instance State and Status Checks: Make sure your instance is running and has passed the instance status checks. This can be done from the EC2 console, under Instance State, it should show as "Running" and under Status Check, it should show "2/2 checks passed". If any of the status checks are failing, see which are and that can help you further identify where the issue is.

If you're still having issues after checking the above items, please reply to this thread with the type of VPC you're using (default or manually created), and if your instance has a public IP or not. Hope that helps!

AWS
answered 22 days ago

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