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
- This error usually occurs after a Glibc or OpenSSL update and the server failed to restart.
- While many distros can install the update to Glibc or OpenSSL and not require a restart, yours may not fall in the same category.
- If you know the update for the Glibc is installed, use lsof to see where the SSHD has open files.
- 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
- It is possible that the users may have exceeded the maximum number of SSH sessions without knowing it.
- Try to clear up the old sessions and then reconnect to the server.
- 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.
- If there are more than 2 users logged in, then kill the user processes one by one.
- 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
- If the issue persists, check for corrupted fingerprints or keys. This is most likely to happen if you have installed these files manually.
- Try removing the server-side fingerprint in the clients ~/.ssh/known_hosts and try again.
- When you re-connect you will be prompted to accept the host identity. Accept and proceed.
- 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
- 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.
- 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.