Fixed ssh_exchange_identification - connection closed by remote host

Fixed ssh_exchange_identification – connection closed by remote host

When using the SSH client, you might get an error message “SSH_exchange_identification: connection closed by remote host”. If you want to find solutions to this problem, you can read this Techquack article. Here are some workable solutions.

When using the SSH client to connect to a server, you might run into the problem “SSH_exchange_identification: connection closed by remote host”. This problem can have several causes, such as problems with the hosts. deny and hosts. allow configuration files.

Let’s see how to solve the “SSH _exchange_identification” problem.

 

What causes the host to close the “ssh_exchange_identification” connection?

What causes the host to close the "ssh_exchange_identification" connection?

Although in many cases the “ssh_exchange_identification: Connection closed by remote host” error may be caused by problems with the hosts. deny and hosts. allow configuration files, the problem may have other causes. If you are reading this, you have probably already checked that these two files do not block your IP address when you try to use ssh on a remote server.

In this case, it could be a dependency problem, memory fragmentation, or even an excessive number of sessions from individual clients. The good news is that once the problem is resolved, you should no longer see this error.

This error indicates that the remote host has suddenly dropped the connection. This is a common error that users get when trying to connect to SSH servers. The main cause of this error may be related to the hosts. deny and hosts. allow configuration files.

 

To troubleshoot the `ssh_exchange_identification` connection closed host

To troubleshoot the `ssh_exchange_identification` connection closed host

Check for missing dependencies
  1. This error usually occurs after a Glibc or OpenSSL update and the server cannot be restarted.
  2. While many distributions can install a Glibc or OpenSSL update without having to reboot, your distribution may not fall into the same category.
  3. If you know that the Glibc update is installed, use lsof to see where in the SSHD the files are open.
  4. If you are using Ubuntu or Debian, use the update command to get and install new packages. This will help you fix any problems that have arisen due to broken packages.
Check for additional SSH sessions
  1. It is possible that users have exceeded the maximum number of SSH sessions without knowing it.
  2. Try deleting the old sessions, then reconnecting to the server.
  3. You should only see one or two connected users at any given time. To check for multiple running SSH instances, use the “Who” command.
  4. If there are more than two users logged in, terminate the user processes one at a time.
  5. Reconnect to the server via SSH and see if the situation has improved.

This problem occurs when SSH cannot follow a script that runs multiple SSH sessions in a row. You can also delay an SSH session by using the “Sleep” command.

Check to see if your fingerprints/keys are damaged
  1. If the problem persists, check for damaged fingerprints or keys. This is especially important if you installed these files manually.
  2. Try removing the server-side fingerprint in the ~/.ssh/known_hosts client and try again.
  3. When you reconnect, you will be prompted to accept the host ID. Accept and continue.
  4. This error can also occur if the /etc/ssh/*key* files are deleted and the SSHD is not restarted. Check the SSH configuration directory for key files.
Check the server boot

This error can also occur if your server is heavily loaded.

  1. Check if the server has enough resources to complete the task, or if it is under a brute force attack.
  2. Try increasing the number of connections that SSHD can make to solve the problem.

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

 

Frequently Asked Questions

The "connection closed by remote host" error is a common one, and few people seem to know what causes it. Some point to /etc/hosts. allow and /etc/hosts. deny files as the cause, others say it could be a hardware failure, sshd configuration, or faulty Glibc updates.

This message indicates that the load on Git Fusion exceeds the "MaxStartups" value set in the sshd_config file. Adjust this setting to resolve this issue; we recommend a minimum value of 100. The sshd_config file is usually located in the /etc/ssh/sshd_config directory.

  1. What causes SSH "Connection reset by peer" error?
  2. Check hosts. deny and hosts. allow files. How to edit hosts. deny file? How to edit hosts. allow file.
  3. Check if fail2ban is blocking your IP address.
  4. Check the sshd_config file.

Go to Settings > Configuration > SSH . There is a section called SSH Settings, check the SSH keepalive option. Then the problem should go away.

 

One Comment

  1. Joe Reply

    I fixed this error by enabling Remote Login in System Preferences / Sharing.

    My reverse port worked for years, but failed after some system settings on the mac were lost in a hardware upgrade. This fixed it.

Leave a Reply

Your email address will not be published. Required fields are marked *