FIX: ssh_exchange_identification connection closed by host


Tashreef Shareef
by Tashreef Shareef
Author
Loading Comments
Affiliate Disclosure

fix ssh_exchange_identification error

While using an SSH client to connect to your server, you may encounter some ugly errors. One such error is the ssh_exchange_identification: connection closed by remote host.

This error can occur due to many reasons including the SSH keys used for a connection being corrupt.

If you are also troubled by this error, here are a couple of troubleshooting tips to help you resolve the ssh_exchange_identification: connection closed by remote host error in Windows.

How can I fix ssh_exchange_identification error?

1. Check for missing dependencies

ssh_exchange_identification: connection closed

  1. This error usually occurs after a Glibc or OpenSSL update and the server failed to restart.
  2. While many distros can install the update to Glibc or OpenSSL and not require a restart, yours may not fall in the same category.
  3. If you know the update for the Glibc is installed, use lsof to see where the SSHD has open files.
  4. If you are using Ubuntu or Debian, use the upgrade command to get new packages and install them. This will help you to fix any issues that may have occurred due to broken packages.

2.  Check for extra SSH sessions

ssh_exchange_identification: connection closed

  1. It is possible that the users may have exceeded the maximum number of SSH sessions without knowing it.
  2. Try to clear up the old sessions and then reconnect to the server.
  3. At any given time, you should see only one or two users logged in. To check if there are multiple instances of SSH running, use the who command.
  4. If there are more than 2 users logged in, then kill the user processes one by one.
  5. Reconnect to the server using SSH and check for any improvements.

This issue occurs if the SSH can’t keep up with a script that starts multiple SSH sessions back to back. You can also delay the SSH session with the sleep command.


3.  Check for corrupted fingerprint/keys

ssh_exchange_identification: connection closed

  1. If the issue persists, check for corrupted fingerprints or keys. This is most likely to happen if you have installed these files manually.
  2. Try removing the server-side fingerprint in the clients ~/.ssh/known_hosts and try again.
  3. When you re-connect you will be prompted to accept the host identity. Accept and proceed.
  4. This error can also show up if the files  /etc/ssh/*key*  are removed and SSHD is not restarted. Check the SSH configuration directory for the key files.

4. Check for server load

ssh_exchange_identification: connection closed

  1. This error can also occur if your server is under heavy load. Check if the server has enough resources to do the task or it is under brute force attack.
  2. Try increasing the amount of connection SSHD can run to resolve the issue.

The ssh_exchange_identification: connection closed by remote host error is a common error and can occur due to missing dependencies or corrupted keys. Follow the steps in this article to fix issues with the SSH client.

If you have any other questions or suggestions, feel free to leave them in the comments section below.

READ ALSO: