Votes: 0Posted On: Oct 10, 2017 01:47:58
The error "ssh_exchange_identification: connection closed by remote host" is caused due to multiple reasons. Some of the reasons and its solution are listed below.
1. Check the "/etc/hosts.allow" and "/etc/hosts.deny" files. As the name suggests, these files contain the name of hosts that are allowed or denied on the system. Please check if the "/etc/hosts.deny" file contains any "sshd: ALL" field. If it does, delete the line. It is preventing any SSH connection to be established. You can also add the field "sshd: ALL" to "/etc/hosts.allow" file.
2. Check the "/etc/ssh" directory that contains all the SSH keys used for connection. It is possible that some of the keys may be corrupt. Please delete the keys from the list and restart the "sshd" service by using the following command.
If you are not able to delete the files, you can forcefully delete them by using the following command.
ssh-keygen -t rsa -f /etc/ssh/name_of_the_key
On restarting the service, the keys will be automatically regenerated.
3. Sometimes, the error occurs when the system exceeds the total number of connections. You can increase the MaxStartups value in the "/etc/ssh/sshd_config" file. You can use the command "grep MaxStartups /etc/ssh/sshd_config" to check the value.