EC2 SSH connection error

0

Hi AWS, I have launched an Amazon Linux 2023 instance. I am connecting the server using SSH client ssh -i "keypair.pem" ec2-user@1.2.3.4. Till last week I was able to login into the server successfully but today while login I am continuously facing the error i.e. kex_exchange_identification: read: Connection reset Connection reset by 1.2.3.4 port 22

I have checked the security group inbound rules as well and nothing has been changed so why I am getting this error suddenly. Please help.

profile picture
asked 14 days ago129 views
3 Answers
1

This does not seem like a network problem because the reset was received by the client after TCP handshake was completed.

It might be that the ssh server process got defunct.

I suggest to restart the instance and check if it solves the problem.

profile pictureAWS
EXPERT
answered 14 days ago
0

Hi,

You should follow the following guidance to understand and fix the cause of your issue: https://repost.aws/knowledge-center/ec2-linux-resolve-ssh-connection-errors

Best,

Didier

profile pictureAWS
EXPERT
answered 14 days ago
0

Here are some steps you can take to troubleshoot and resolve the issue:

**Check Instance Status: ** Ensure that your EC2 instance is running and reachable. You can check the instance status in the AWS Management Console under the EC2 service.

**Verify Security Group Rules: **

Confirm that the inbound rules of your instance's security group allow SSH (port 22) traffic from your IP address or from any IP (0.0.0.0/0) if you're unsure. Sometimes security group rules can be accidentally changed, so double-check to ensure they are still configured correctly.

Check Key Pair:

Make sure you're using the correct key pair (keypair.pem) to connect to your instance. Ensure that the permissions on the key pair file are set correctly. It should only be readable by the owner (chmod 400 keypair.pem).

Review System Logs:

Check the system logs on your EC2 instance for any errors or issues that might be causing the connection reset. You can access the system logs by connecting to your instance using the EC2 Instance Connect feature or by using the AWS Systems Manager Session Manager.

Restart Instance:

If possible, try restarting your EC2 instance to see if that resolves the issue. Sometimes a simple reboot can fix connectivity problems.

**Network Connectivity: ** Check if there are any network issues or restrictions on your side that might be causing the connection reset. Test SSH connectivity from a different network or from a different machine to rule out local network issues.

**Security Software or Firewall: ** If you're connecting from a corporate network or using security software on your local machine, ensure that it's not blocking SSH connections. Similarly, check if there are any firewall rules or network security devices (e.g., IDS/IPS) that might be interfering with the connection.

answered 14 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