SSH starts timing out into my EC2 instances after a few minutes

0

As mentioned My EC2 instance allows me to connect via SSH for a while but after 10ish minutes they disconnect and all subsequent requests time out. I've seen this with both Ubuntu and AmazonLinux2024 images.

I believe I'm having this problem but cannot figure out how to file a technical support ticket. https://repost.aws/questions/QUiMEROPieSmK3kw-3b6Kvlw/cannot-ssh-into-any-ec2s-a-few-minutes-after-starting

I've contacted billing support which was unhelpful and referred me here.

asked 21 days ago42 views
1 Answer
-1

The issue you're experiencing with SSH connections timing out after a few minutes on your EC2 instances could be caused by several factors. Here are some potential solutions and troubleshooting steps:

  1. Enable SSH keepalives: Add the following lines to your local SSH config file (~/.ssh/config):

    ServerAliveInterval 59 ServerAliveCountMax 3

    This will send a small packet every 59 seconds to keep the connection alive.

  2. Check your security group and network configuration:

    • Ensure port 22 is open for inbound SSH traffic in your security group.
    • Verify that your VPC has an Internet Gateway attached.
    • Check that the subnet's route table has a route to the Internet Gateway.
    • Confirm that Network ACLs are not blocking incoming SSH traffic.
  3. Review instance resource utilization:

    • Monitor CPU, memory, and network usage of your instances.
    • Consider upgrading to a larger instance type if resource constraints are an issue.
  4. Investigate potential software conflicts:

    • Review any recently installed software or updates that might be interfering with the SSH service or network connectivity.
  5. Use alternative access methods:

    • Try EC2 Instance Connect or AWS Systems Manager Session Manager to access your instance when SSH is unresponsive.
  6. Check system logs:

    • After restarting the instance, review system logs (/var/log/syslog or /var/log/messages) for any error messages or indications of what might be causing the issue.
  7. Enable detailed CloudWatch monitoring for your EC2 instances to get more granular data on their performance and potential issues.

If the problem persists after trying these solutions, it may be worth creating a new instance with the same configuration to determine if the issue is specific to your current instances. Additionally, if you have an appropriate support plan, you can open a technical support case through the AWS Support Center in the AWS Management Console. Select "EC2 Instance" as the service, and provide detailed information about your issue, including instance IDs, timestamps of when the problems occur, and any troubleshooting steps you've already taken.

Sources
EC2 ssh closes my connection, but not for others | AWS re:Post
Intermittent SSH timeout hangs EC2 instance | AWS re:Post

profile picture
answered 21 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