我在远程盒子上运行Ubuntu 10.10。我每天都没有问题,但今天突然出现,我得到以下错误:
ssh_exchange_identification: Connection closed by remote host
如果我连接 -vv
,我得到以下内容:
OpenSSH_5.6p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /Users/bla/.ssh/config
debug1: Applying options for ubuntu-server
debug1: Reading configuration data /etc/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to ubuntu-server.com [123.123.123.123] port 22.
debug1: Connection established.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug2: key_type_from_name: unknown key type '-----END'
debug1: identity file /Users/bla/.ssh/id_rsa type -1
debug1: identity file /Users/bla/.ssh/id_rsa-cert type -1
ssh_exchange_identification: Connection closed by remote host
如果我删除密钥,我得到完全相同的输出(没有“debug2:key_type _...)。我已设法登录并检查了我的 hosts.allow
和 hosts.deny
但他们没有参赛作品。我尝试删除并重新安装OpenSSH,检查 authorized_keys
和 ~/.ssh
权限并尝试从其他计算机连接只是为了得到相同的错误。我在我的智慧结束,任何帮助将不胜感激。
同样的错误
ssh_exchange_identification:远程主机关闭连接
私钥(文件)可被所有人读取,即具有错误的权限时发生。
例如,如果有任何私钥
ssh_host_key
ssh_host_dsa_key
ssh_host_rsa_key
在 /etc/ssh/
是 chmod 644
(应该 chmod 600
)。
以下权限导致“ssh_exchange_identification:远程主机关闭连接”错误:
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
现在应该接受更正的权限,连接:
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
几乎可以肯定的是 /etc/hosts.deny
文件有你的机器的条目,添加
sshd: xxx.yyy.zzz.aaa
将您的连接IP地址添加到/etc/hosts.allow
-rw------- 1 user group 405 2011-10-29 10:20 authorized_keys2
authorized_keys2
是 弃用 从3.0版开始。
debug3: Not a RSA1 key file /Users/bla/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
看起来您的私钥已损坏。重新生成密钥对,使用 ssh-copy-id
将您的公钥安装到 authorized_keys
文件,然后再试一次。
在做某事之间是否会有新的防火墙。我曾经遇到过一个问题,在一个新的防火墙引入了同样的问题。新的防火墙是在服务器端引入的。