The same error

ssh_exchange_identification: Connection closed by remote host

happens when private keys (files) are readable by all, i.e. have the wrong permissions.

For example, if any of the private keys

  • ssh_host_key
  • ssh_host_dsa_key
  • ssh_host_rsa_key

in /etc/ssh/ are chmod 644 (should be chmod 600).

The following permissions results in “ssh_exchange_identification: Connection closed by remote host” error:

[email protected]:/etc/config/ssh# ls -la
drwxrwxrwx    2 root     root            0 Aug 24  2005 .
drw-rw-rw-    3 root     root            0 Apr  3  2007 ..
-rw-r--r--    1 root     root        88039 Aug 24  2005 moduli
-rw-r--r--    1 root     root         1559 Aug 24  2005 ssh_config
-rw-r--r--    1 root     root          668 Aug 24  2005 ssh_host_dsa_key
-rw-r--r--    1 root     root          599 Aug 24  2005 ssh_host_dsa_key.pub
-rw-r--r--    1 root     root          524 Aug 24  2005 ssh_host_key
-rw-r--r--    1 root     root          328 Aug 24  2005 ssh_host_key.pub
-rw-r--r--    1 root     root          883 Aug 24  2005 ssh_host_rsa_key
-rw-r--r--    1 root     root          219 Aug 24  2005 ssh_host_rsa_key.pub
-rw-r--r--    1 root     root         2018 Aug 25  2005 sshd_config

Corrected permissions, connections should now be accepted:

[email protected]:/etc/config/ssh# ls -la                    
drwxrwxrwx    2 root     root            0 Aug 24  2005 .
drw-rw-rw-    3 root     root            0 Apr  3  2007 ..
-rw-r--r--    1 root     root        88039 Aug 24  2005 moduli
-rw-r--r--    1 root     root         1559 Aug 24  2005 ssh_config
-rw-------    1 root     root          668 Aug 24  2005 ssh_host_dsa_key
-rw-r--r--    1 root     root          599 Aug 24  2005 ssh_host_dsa_key.pub
-rw-------    1 root     root          524 Aug 24  2005 ssh_host_key
-rw-r--r--    1 root     root          328 Aug 24  2005 ssh_host_key.pub
-rw-------    1 root     root          883 Aug 24  2005 ssh_host_rsa_key
-rw-r--r--    1 root     root          219 Aug 24  2005 ssh_host_rsa_key.pub
-rw-r--r--    1 root     root         2018 Aug 25  2005 sshd_config

Leave a Reply

Your email address will not be published. Required fields are marked *