Kex_exchange_identification: read: Connection reset by peer error on Linux

I cannot connect to my Ubuntu Linux server using the ssh client from my Windows 10 desktop. I am trying to log in my remote server:

ssh user@server_IP_ADDRESS

But getting message or error as follows:

kex_exchange_identification: read: Connection reset by peer

What could cause such issue?

My best guess is Firewall. Try passing the -v option and see what it says:

ssh -v user@server_IP_ADDRESS
ssh -vv user@server_IP_ADDRESS
ssh -vvv user@server_IP_ADDRESS

The -v option causes ssh to print debugging messages about its progress. This is helpful in debugging connection, authentication, and configuration problems. Multiple -v options increase the verbosity. The maximum is 3.

You might need to run the SSH Server with higher logging too, but even then you probly get nothing to indicate what’s wrong, like I’ve faced at least half a dozen times.

It means the remote server closed the Transition Control Protocol (TCP) stream. My experience suggests that your IP on purpose or by accident is blocked by server firewall or DenyHosts.

  1. Are you running DenyHosts? Can you check for theDenyHosts og?
  2. Check your firewall log
  3. See if your IP blocked using the iptables: sudo iptables -L --line-number -v -n | grep your-ip
  4. Check /etc/hosts.deny and /etc/hosts.allow files
  5. Check sshd /var/log/auth.log and /var/log/security log files
  6. Restart the server or restart the ssd service. Does that fix the problem?

Hey all,

Thank you for all of your valuable suggestions and for helping me. The problem is I cannot ssh and run anything at all. This is an EC2 instance. My Apache is still working. I don’t know what is going on with ssh server?

After searching a lot I can debug using serial console but there is no option on this old instance. Now I am reading Resolve EC2 SSH connection errors using the AWSSupport-TroubleshootSSH automation workflow this. It is all way too complicated for me.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki