Ssh exchange identification: Connection closed by remote host

From LinodeWiki

Jump to: navigation, search

[edit] About, and fixing this error.

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.

This will lock you out of SSH, according to your IP, so lets open up a Lish connection:

    ssh linode#####@datac###.linode.com (Find your Lish info inside your Linode Manager.)

Fill out your Ubuntu username/password. Preferably, use your root.

    nano /etc/hosts.deny

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

    sshd: [your ip]

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

    /etc/init.d/ssh restart

We're only half done. Log out of Lish, and log back into your normal SSH.

This problem will often repeat itself, so lets fix it so it won't happen again.

    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!

Personal tools