ssh_exchange_identification: “connection closed by remote host Ubuntu”

When attempting to connect to Ubuntu servers, do you keep getting the message “ssh_exchange_identification: connection ended by remote host”?

Well, this problem happens because of improper SSH configuration or server-side limitations. In other words, this connection request could come from two independent sources of addresses and be recognized by servers as such. If you are using a VPN or proxy server, this may occur. When a client connects to the internet via a mobile device or mobile hotspot, it is also possible to get this issue.

Our professionals at Hiremyadmin will closely collaborate to troubleshoot the concerned issue after it is reported by any of our clients.


What is the reason for failing of ssh_exchange_identification?

A secure remote connection between two machines can be established using the SSH protocol. Recently, when one of our clients attempted to log in through SSH to their server, an error message was immediately displayed.

“ssh_exchange_identification connection closed by remote host”

It may occasionally occur due to issues with the host side. This error signifies that the connection is closed by the remote host. If a user attempts to connect via SSH to a server, they frequently get this problem. The configuration files host.deny and host.allow are the primary cause.

What can be done to fix ‘ssh_exchange_identification: connection closed by the remote host’ error?

When you see the error message “ssh exchange identification connection closed by remote host,” it must be annoying. You are prevented from logging into the remote system by this error. Any virtual system cannot be accessed by a user without authorization. So how can I fix the connection closed by the remote host problem? 

Yes, thankfully, there are several methods that may be used to solve this horrifying issue. Let’s investigate.

  • Looking into hosts.deny and hosts.allow files

 The restriction of the server is one of the most frequent sources of errors. Most likely, these are the host.allow and host.deny configuration files that are used to control network traffic and to decide which users can access resources and which ones must be blocked. By default, any user can view the data if you don’t make any changes to these two files. But if the error bothers you, you must examine both files very carefully. Indicate the remote host’s IP address in both configuration files to permit access.

  • Adding absent dependencies

A different solution is to see if any files have been destroyed by the ssh daemon. Sometimes, it is pretty evident that any missing dependencies may have caused the error that occurred. We need to run a command to check these.

grep DEL | ssh | lsof -n

If you still didn’t receive anything, restart the system by going back. Update the SSH server later, then add dependencies.

  • Checking memory fragmentation

Splitting memory on the host side is an additional factor that might exist. Memory fragmentation may result from a host that lacks swap partitions. The command shown below is used to verify the memory utilization state of the services currently being used.

VM Statue -S

Then, we restart the memory-related services, such as MySQL, Apache, Nginx, etc.

  • Checking for extra ssh instances

Checking the availability of the maximum number of SSH connections is another way to resolve the issue. It’s a good idea to look at how many user processes are active. To accomplish this, use the command,


We destroy the user processes and retry the connection if it indicates there are numerous concurrent users logged in.

  • Checking and increasing sshd connection limit

 It may also be a factor in connections closed by remote host errors if the maximum allowed number of ssh connections is checked and found to be very few. Ten simultaneous ssh connections are typically allowed by default, which should be sufficient for the majority of servers. Utilize the following command to attempt to raise the MaxStartup value:

 Root:- # grep


  • Looking for and removing ssh fingerprint/keys

Corrupt fingerprints or keys is another factor contributing to this issue. Therefore, we attempt to connect after removing the server-side fingerprints from the clients’ /.ssh/known hosts. If it works, we switch the key.

  • Reducing server load

We look for the load-causing processes when a heavy server load rejects an ssh connection. We will take action to halt it if it is an attack of any type. It will help in getting back the SSH access.



The root cause of Ubuntu’s “ssh exchange identification connection closed by remote host” error could be server limits or improper ssh configuration. Additionally, we discovered

how to correctly remedy it. We are hoping this post will assist you in finding a solution. If things don’t work, we are always available to help you.