ssh exchange identification: Connection closed by remote host

This error is caused by problems in your hosts.deny. If you installed all the recommended packages in Ubuntu, you’ll most likely have Denyhosts. If not, /etc/hosts.deny won’t exist, thus this tutorial will not apply to you.

First, ssh to your server via another IP

Open this file:

nano /etc/hosts.deny

Find your IP, and clear the line. It’ll look like:

sshd: [your ip]

You can put # symbol to comment it if you want.

Now lets save and exit out of nano, and restart SSH.

/etc/init.d/ssh restart

Done. Log out, and log back to verify.

If this problem will often repeat itself, so lets fix it so it won’t happen again.
Open this file:

nano /etc/hosts.allow

Scroll to the very bottom, and type this on a new line:

sshd: [your ip]

Save nano, and exit out. Then, restart SSH.

/etc/init.d/ssh restart

Voila, problem solved!

Any Comments?