Connecting to Ubuntu EC2 Instance Timed Out

0

Hi there, I started an instance of Ubuntu EC2. I initially connect it via EC2 Instance Connect and installed Nginx into it. Then I change the security groups and created a new one. Inside it I allowed ; All traffic from IPv4, All traffic from IPv6 , SSH from port 22 for IPv4, SSH from port 22 for IPv6, as both inbound and outbound rules. After that I was convenient to visit my public IP address from my browser by going to http://MY_PUBLIC_IP_ADDRESS and I can see the Nginx screen. Everything was okay. Then, I checked my all subnets and route tables. All of them has 0.0.0.0/0 as destination and an Internet Gateway as target. Then I go to my Network ACLs and allowed the SSH from port 22 and SSH from ports between 1024 - 65535 for both inbound and outbound rules.

Then I installed OpenSSHServer package to my Windows laptop and started it. Closed the firewall... However, when I try to use Putty for SSH connection I get connection timed out. When I try to connect with SSH Client, it timed outs too. I tried with different internet connection too, nothing changed. I'm really freaked out and really don't know what to do. So please help me...

2 Answers
0

Hi, you said you could initially connect via EC2 Instance Connect. Can you still do this from the AWS console?

If you're not able to connect at all have you tried using Session Manager?

Have you tried using a key pair to connect with SSH?

Have you tried opening up your NACLs again temporarily to diagnose which changes are causing you trouble? For just SSH purposes you should only need port 22 inbound and ports 1024-65535 outbound. Your Security Group should only need port 22 inbound, nothing outbound as it's stateful.

EXPERT
answered a year ago
  • Hi, thanks for your answer. No, I can't connect via EC2 Instance Connect anymore. Session Manager gives warning: The required IAM instance profile isn't attached to the instance. You can attach a profile using AWS Systems Manager Quick Setup. Yes, I'm trying to connect via my converted-key.ppk file. With your said, I changed my NACLs as SSH 22 for inbound and 1024-65535 for outbound only. And set to my security group just SSH 22 inbound and deleted all outbound rules. Unfortunately, nothing changed.

0

I would try getting back to a known-good state, undoing everything you've done since last being able to connect via EC2 Instance Connect. Also try creating another temporary EC2 instance in a different subnet with a different NACL that's fully open, and a new different Security Group with all inbound open, and verify you can connect to it. Then bit by bit make this more like your original instance until you find what breaks it.

EXPERT
answered a year 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