O mesmo erro
ssh_exchange_identification: Connection closed by remote host
acontece quando as chaves privadas (arquivos) são legíveis por todos, ou seja, possuem as permissões erradas.
Por exemplo, se alguma das chaves privadas
-
ssh_host_key
-
ssh_host_dsa_key
-
ssh_host_rsa_key
em /etc/ssh/
são chmod 644
(deve ser chmod 600
).
As seguintes permissões resultam no erro "ssh_exchange_identification: Conexão fechada pelo host remoto":
root@host:/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
Permissões corrigidas, as conexões agora devem ser aceitas:
root@host:/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