SSH客户端问题:连接重置通过peer

我在Ubuntu笔记本电脑上遇到了一个令人讨厌的问题。

我在升级到Ubuntu 11.04之后,今天注意到了这一点,尽pipe我不确定这是几天前我用ssh密钥玩的原因。

问题是,每当我尝试SSH到任何主机,我得到以下错误:

Read from socket failed: Connection reset by peer 

使用-vvv运行提供以下输出:

 OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to hostname [10.0.0.2] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: identity file /root/.ssh/id_dsa type -1 debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: Remote protocol version 1.99, remote software version OpenSSH_4.2 debug1: match: OpenSSH_4.2 pat OpenSSH_4* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3 debug2: fd 3 setting O_NONBLOCK debug3: load_hostkeys: loading entries for host "hostname" from file "/root/.ssh/known_hosts" debug3: load_hostkeys: loaded 0 keys debug1: SSH2_MSG_KEXINIT sent Read from socket failed: Connection reset by peer 

我的/ etc / ssh / ssh_config:

 Host * SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication no GSSAPIDelegateCredentials no 

我可以从任何其他服务器通过SSH连接到我的笔记本电脑,我也可以从我的笔记本电脑ssh localhost成功。

我可以从其他笔记本电脑连接到所有这些其他服务器,我没有看到其他服务器的日志中有关我的失败尝试。

我试图阻止iptables,没有帮助。

我尝试了几个技巧,我可以find我的/ etc / ssh / ssh_config在线,但我没有成功解决问题…

有任何想法吗?


编辑:这是我尝试连接的主机之一的日志:

 May 1 19:15:23 localhost sshd[2845]: debug1: Forked child 2847. May 1 19:15:23 localhost sshd[2845]: debug3: send_rexec_state: entering fd = 8 config len 577 May 1 19:15:23 localhost sshd[2845]: debug3: ssh_msg_send: type 0 May 1 19:15:23 localhost sshd[2845]: debug3: send_rexec_state: done May 1 19:15:23 localhost sshd[2847]: debug1: rexec start in 5 out 5 newsock 5 pipe 7 sock 8 May 1 19:15:23 localhost sshd[2847]: debug1: inetd sockets after dupping: 3, 3 May 1 19:15:23 localhost sshd[2847]: Connection from 10.0.0.7 port 55747 May 1 19:15:23 localhost sshd[2847]: debug1: Client protocol version 2.0; client software version OpenSSH_5.8p1 Debian-1ubuntu3 May 1 19:15:23 localhost sshd[2847]: debug1: match: OpenSSH_5.8p1 Debian-1ubuntu3 pat OpenSSH* May 1 19:15:23 localhost sshd[2847]: debug1: Enabling compatibility mode for protocol 2.0 May 1 19:15:23 localhost sshd[2847]: debug1: Local version string SSH-2.0-OpenSSH_5.3 May 1 19:15:23 localhost sshd[2847]: debug2: fd 3 setting O_NONBLOCK May 1 19:15:23 localhost sshd[2847]: debug2: Network child is on pid 2848 May 1 19:15:23 localhost sshd[2847]: debug3: preauth child monitor started May 1 19:15:23 localhost sshd[2847]: debug3: mm_request_receive entering May 1 19:15:23 localhost sshd[2848]: debug3: privsep user:group 74:74 May 1 19:15:23 localhost sshd[2848]: debug1: permanently_set_uid: 74/74 May 1 19:15:23 localhost sshd[2848]: debug1: list_hostkey_types: ssh-rsa,ssh-dss May 1 19:15:23 localhost sshd[2848]: debug1: SSH2_MSG_KEXINIT sent May 1 19:15:23 localhost sshd[2848]: debug3: Wrote 784 bytes for a total of 805 May 1 19:15:23 localhost sshd[2848]: fatal: Read from socket failed: Connection reset by peer 

这是一个难以debugging的openssh,它似乎只发生在特定的客户端到特定的服务器。

  1. 原因? 我没有得到根本原因。 我最好的发现是,连接数据包太大,服务器无法处理,连接重置。

  2. 解决方法:限制数据包大小。 两种select:

    • 通过在ssh命令行中使用'-c'来限制密码列表长度,例如'-c aes256-ctr'
    • 通过添加〜/ .ssh / config来限制HostKeyAlgorithms列表:

      HostKeyalgorithmssh-rsa-cert-v01 @ openssh.com,ssh-dss-cert-v01 @ openssh.com,ssh-rsa-cert-v00 @ openssh.com,ssh-dss-cert-v00 @ openssh.com,ecdsa -sha2-nistp256,ECDSA-SHA2-nistp384,ECDSA-SHA2-nistp521,SSH-RSA,SSH-DSS

  3. url:

    • Ubuntu的bug: https : //bugs.launchpad.net/ubuntu/+source/openssh/+bug/708493
    • 我的线程在openssh-unix-dev列表中: http : //lists.mindrot.org/pipermail/openssh-unix-dev/2011-February/029361.html
  4. 受影响的版本:AFAIK它开始于5.7p1。 降级到5.5p1解决了这个问题。 但是,在没有这个问题的机器上,5.7p1,5.8p1完美地工作。 因此,我的假设是,它必须与5.7p1上添加到第三方lib的无辜图书馆电话相关联,而第三方lib仅在特定环境中被打破。 疯狂的假设一个疯狂的错误。

这对我工作:

我的/etc/ssh/ssh_config

 Host * SendEnv LANG LC_* HashKnownHosts yes GSSAPIAuthentication yes GSSAPIDelegateCredentials no Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc 

这是因为连接数据包太大,服务器无法处理,连接被重置。 你可以把Chippersconfiguration放在/etc/ssh/ssh_config …所以只需要用ssh -l username hotname就可以了,不需要-c aes256-ctr了。

当我在一个特定的无线连接时发现这个错误。 当我改变了一个不同的无线networking,错误消失了。 奇怪,但真实: – /