ssh_exchange_identification无处不在:连接被远程主机关闭


14

我在远程机器上运行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.allowhosts.deny但没有任何条目。我尝试删除并重新安装OpenSSH,然后检查authorized_keys~/.ssh权限,并尝试从其他计算机连接以得到相同的错误。


2
您能否将输出发布-vvv并获得~/.ssh文件夹和~/.ssh/authorized_keys文件的许可?
量子

1
另外,您可以粘贴sshd_config以及host.allow / host.deny文件吗?顺便说一句,您可以在本地连接:ssh localhost吗?
Rilindo 2011年


@quanta -vvv日志可在此要点找到,权限为drwx------ 2 user group 4096 2011-10-29 10:27 .ssh-rw------- 1 user group 405 2011-10-29 10:20 authorized_keys2。@rilindo我的sshd_config和host.allow / deny也可以在要点中找到。再次感谢您的帮助!
卡洛斯,

1
我看不到sshd_config-但如何处理:使用如下调试在备用端口上运行sshd:/ usr / sbin / sshd -p222 -d -f / etc / ssh / sshd_config
Rilindo 2011年

Answers:


3

同样的错误

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

1
如果说“主键对不应该是世界可写的”而不是“ ssh_exchange_identification:Gobble De Goop”,那将是很好的选择,但是请注意,这就是我遇到的问题。
达斯汀·格雷厄姆

2

几乎可以肯定该/etc/hosts.deny文件为您的机器添加了一个条目,添加

sshd: xxx.yyy.zzz.aaa

将您的连接IP地址连接到/etc/hosts.allow


h!我自己的花火悬挂,似乎
bitcruncher

1
-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文件中,然后重试。


1

在做某事之间是否可以有一个新的防火墙。我曾经遇到一个问题,即在引入的新防火墙中出现了完全相同的问题。新的防火墙是在服务器端引入的。


0

这里可能有几个问题。

  1. 服务器是否配置为限制接受的身份验证类型?可以使用文件中的各种*Authentication指令进行设置sshd_config
    • 如果您使用PAM进行身份验证,请检查其配置
  2. 您的密钥似乎采用了其他格式。查看ssh-keygen -e -i-m标志。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.