- The ssh_exchange_identification: connection closed by remote host Windows error points to server issues or missing dependencies.
- Your primary approach should be to verify the server load and reduce it.
- For some users, removing multiple instances of SSH did the trick!
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 in Windows. The error appears on other operating systems as well.
This error can occur due to many reasons, including the SSH keys used for a connection being corrupt or issues with the server. Keep reading to find out how you can fix things when a ssh connection is closed by a remote host immediately!
How do I fix connection closed by remote host?
Before we move to the slightly complex solutions, verify these first:
- This error can also occur if your server is under heavy load. Check if the server has enough resources to do the task or if it is under brute force attack.
- Increasing the amount of connection SSHD can run to resolve the issue.
If none work, head to the fixes listed next.
How we test, review and rate?
We have worked for the past 6 months on building a new review system on how we produce content. Using it, we have subsequently redone most of our articles to provide actual hands-on expertise on the guides we made.
For more details you can read how we test, review, and rate at WindowsReport.
1. Check for missing dependencies
This ssh_exchange_identification: connection closed by remote host Windows error usually occurs after a Glibc or OpenSSL update and the server fails 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. For those using Ubuntu or Debian, use the upgrade command to get new packages and install them. This will help fix any issues that may have occurred due to broken packages.
2. Check for extra SSH sessions
- 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 following command:
- If there are more than two users logged in, then kill the user processes one by one.
- Reconnect to the server using SSH and check for any improvements.
It is possible that the users may have exceeded the maximum number of SSH sessions without knowing it.
This ssh_exchange_identification: connection closed by remote host error in Windows or Linux 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 fingerprints/keys
- Remove 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.
If the issue persists, check for corrupted fingerprints or keys. This is most likely to happen if you have installed these files manually.
Once done, find out whether the connection is still lost after the ssh_exchange_identification connection closed by remote host lost connection error. In all likelihood, things should be up and running.
Before you leave, find out some quick and easy tips to improve the performance of your Windows PC.
If you have any other questions or suggestions, feel free to leave them in the comments section below.