ssh_exchange_identification: Connection closed by remote host

Double check the perms on your .ssh dir and your .ssh/authorized_keys file. Those need to be chmod 700 and 600 respectively.


I'm pretty sure

sshd: ALLOW

is invalid syntax for hosts.allow. You probably mean ALL, not ALLOW.


You can get "ssh_exchange_identification: Connection closed by remote host" if your sshd service is not operational!

If you have access to the server check you have the sshd service running with:

  ps aux | grep ssh

and check it is listening on port 22:

 netstat -plant | grep :22

more details here


I had a similar error message. I was trying to ssh from MacOS X 10.6.3 to Ubuntu Server 9.04.

I found out that denyhosts on Ubuntu would forcibly insert the following into by /etc/hosts.deny:

sshd: nnn.nnn.nnn.nnn

Even when deleting this entry and restarting denyhosts, this line would return.

In order to fix this, I followed this FAQ to remove my blocked IP address from the specified files in the WORKING_DIR (/var/lib/denyhosts in Ubuntu).

Mind you, as I write this, I am 20 minutes out of having resolved this as far as I can see - I shall advise if I experience a regression.