Skip to content

SSH connection timed out, tried all troubleshooting steps

0

I created a free-tier AWS account, which I accidentally upgraded but carried over the free credits, so I didn't have any issues. But, whenever I try to connect to EC2 instances from my machine with SSH, it always gets connection timed out.

I have tried all the troubleshooting steps I could find online for connecting with SSH--

  • Ensure the instance is running and passed the status checks.
  • SSH traffic is allowed through the instance's Security Group and NACL.
  • Disabled firewall in both the instance and my machine.
  • Ensured that the key is added to ~/.ssh/authorized_keys file of the instance.
  • Created new keys in my machine and added them to ~/.ssh/authorized_keys.
  • Tried all the above with different instance types and in different regions.

I followed the posts/articles below--

The replies in the last post points out that the free-tier EC2 instances like t2 or t3 are have too little resources to run something and have an SSH connection. But I'm unable to connect to them even when it's newly created one, running nothing except the OS. Besides, I'm able to connect from one instance to another when the key is added to ~/.ssh/authorized_keys.

I can't make any sense of this issue. I tried creating a support case, but I was told to either post here or upgrade to premium support for this free-tier functionality. And that's over the fact that I'm not even able to create a support case with the appropriate team, only with Accounts and Billing or Limit Increasing.

Any help will be appreciated. Thanks!

4 Answers
0

Can you also share target instance's details including public IP information? (* Note : You can share partial address information for your security.)

Also I wonder you could access your instance from local (another instance in another subnet) to make sure.

AWS
EXPERT
answered 12 days ago
  • Hi, thanks for checking my post. Apologies for the late reply.

    There's nothing specific about the IP addresses that I have noticed. I get IP addresses starting with "3.x.x.x" to "65.x.x.x". I didn't create another VPC and subnet for the test you suggested, but I created two instances in different regions: ap-south-1 and ap-southeast-1, which should be guaranteed to be in different subnets. I was able successfully connect to the other instance from both of them.

  • No worries and thanks for sharing more details. Then, how about running following commands from your both each local machines and instances in different regions worked before with ssh?

    · telnet <instance-public-IP> 22 or nc -zv <instance-public-IP> 22

0

Hello.

What kind of error do you get when SSHing to EC2 from your PC?
If you get a timeout error, there is likely a problem with your network settings.
For other errors, it is highly likely that SSH communication has reached the EC2 instance, so I recommend checking SSH logs such as "/var/log/secure."
Please note that the file name of the SSH log varies depending on the OS.

EXPERT
answered 13 days ago
AWS
EXPERT
reviewed 13 days ago
  • When I run the command mentioned in the SSH Client tab of the Connect to instance page, I get the "port 22: Connection timed out" error. Same case for using the public IPv4 address with ssh -i /path/to/private_key ubuntu@<instance_IP_address> command.

    I have allowed SSH connection through my firewall, and also tried with firewall disabled. I tried the -vvv flag, which shows that my machine is able to resolve the instance's IP address, but unable to connect to it.

    It doesn't make sense if it's my network that's having issues. I tried on a different computer on the same network and got the same error. I'm able to SSH into other computers in my network, and previously was able to SSH into Oracle Cloud VPS, which they disabled it for free tier. Could it be similar to Oracle Cloud, where AWS has disabled remote SSH for free tier accounts? I still have credits, so I should be able to connect.

0

Based on the troubleshooting steps you've already completed, there are a few additional areas to investigate for SSH connection timeout issues:

Verify your route table configuration: Ensure that your route table has a route that directs traffic to an internet gateway for public subnets. Without proper routing, your instance won't be reachable from the internet even if security groups and NACLs are configured correctly.

Check your source IP address: Confirm that the security group rules allow incoming SSH traffic specifically from your current IP address. If your IP address has changed or if the rule is too restrictive, connections will time out. Make sure port 22 is open for inbound traffic from your actual source IP.

Verify network ACL ephemeral ports: While you've checked that your NACL allows SSH traffic, also confirm that it allows outbound traffic on ephemeral ports (typically 1024-65535). Network ACLs are stateless, so both inbound and outbound rules must be properly configured for the connection to work.

Confirm the correct username: Ensure you're using the correct default username for your specific AMI type (e.g., "ec2-user" for Amazon Linux, "ubuntu" for Ubuntu, "admin" for Debian).

Since you mentioned you can connect between instances when keys are properly configured, this suggests the issue is likely related to network routing or your local network configuration rather than the instance itself. The fact that this occurs across different regions and instance types also points to a networking configuration issue rather than resource constraints.

Consider testing the connection from a different network or location to help isolate whether the issue is with your local network or ISP blocking outbound SSH connections.
Sources
Troubleshoot issues connecting to your Amazon EC2 Linux instance - Amazon Elastic Compute Cloud
Resolve EC2 connection and startup issues | AWS re:Post

answered 13 days ago
EXPERT
reviewed 13 days ago
0

I double-checked the NACL, Route Tables, Security Group and Subnets. Below are the screenshots with the placeholder/removed IDs. I have 3 subnets with identical route tables and NACL rules. Subnet Route Table Subnet Network ACL Security Group rules VPC Resource Map

answered 12 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.