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!

질문됨 5달 전568회 조회
1개 답변
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
답변함 한 달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠