Error establishing SSH connection to your instance. Access to EC2 has been lost

0

I'm using the EC2 instance which is running and already in active state.

I was accessing the instance fine using SSH until today when I started to receive errors about the SSH connection during connecting via aws Dashboard.

Failed to connect to your instance Error establishing SSH connection to your instance. Try again later.

I can't access the instance via aws or my already set-up SSH from my local machine. I tried to access the server via CloudShell but received the below error.

*kex_exchange_identification: read: Connection reset by peer Connection reset by 3.106.132.196 port 22 * Very concerned about this issue as I need to make some urgent changes to the server. Any quick help would be appreciated.

asked 2 months ago76 views
4 Answers
0

I understand your concern about not being able to access your EC2 instance. This is a critical issue, especially when you need to make urgent changes. Let's go through some troubleshooting steps to help resolve this problem:

  1. Check your security group settings: Ensure that your security group allows inbound SSH traffic (port 22) from your IP address. If you're trying to connect from a different location or if your IP has changed, you may need to update this.

  2. Verify the instance state: Confirm that your instance is still in the "running" state and has passed all status checks in the EC2 console.

  3. Check for network issues: Verify that your VPC and subnet configurations are correct and that your instance has a valid route to the internet.

  4. Examine system logs: If possible, check the system logs in the EC2 console for any error messages or indications of what might be causing the connection issues.

  5. Try connecting using EC2 Instance Connect: If you haven't already, attempt to connect using EC2 Instance Connect through the AWS Management Console. This method doesn't rely on your local SSH key and might work even if traditional SSH is failing.

  6. Check for SSH service issues on the instance: The error message you received from CloudShell suggests there might be a problem with the SSH service on your instance. This could be due to misconfiguration, a full disk, or other system issues.

  7. Consider using EC2 Rescue for Linux: If you still can't connect, you might need to use EC2 Rescue for Linux. This is an AWS tool that can help diagnose and fix common issues that prevent connecting to an instance.

  8. As a last resort, you may need to stop and start the instance: This will migrate it to a new host. Be aware that this will change the public IP address if you're not using an Elastic IP.

If none of these steps resolve the issue, you may need to contact AWS support for further assistance. They can help investigate deeper issues that might be preventing access to your instance.

Remember to regularly back up your important data and consider implementing a high availability setup to minimize downtime in the future.
Sources
Troubleshoot issues connecting to your Amazon EC2 Linux instance - Amazon Elastic Compute Cloud
Connect to a Linux instance using EC2 Instance Connect - Amazon Elastic Compute Cloud

profile picture
answered 2 months ago
profile picture
EXPERT
reviewed 2 months ago
0

Check to see if it’s Public IP addresses has changed which do with EC2s if you haven’t reserved an elastic IP

profile picture
EXPERT
answered 2 months ago
0

The IP address seems the same as the website hosted on the server a year ago still running. If the IP has been changed, I believe AWS EC2 instance "Connect" should still work!? I'm blocked from AWS ec2 connect instance and from SSH too.

I restarted the instance and I'm getting Network error now - Enter image description here

The configuration hasn't been changed since last access so not sure what is happening.

answered 2 months ago
0

Hello,

If you are connecting using an AWS EC2 Instance Connect, you need to allow port 22 to AWS IPs based on your region. In the link, you can search for "EC2_INSTANCE_CONNECT" and note the IP addresses based on your region, then allow port 22 to those IPs in the inbound rules.

Alternatively, you can execute the following curl command to filter and display the EC2 Instance Connect IPs:

$ curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq '.prefixes[] | select(.service == "EC2_INSTANCE_CONNECT")'

profile picture
answered 2 months 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