ssh_exchange_identification: Connection closed by remote host

今天在ssh的时候碰到一台机器,遇到了下面的这种情况

$ ssh x.x.x.x
ssh_exchange_identification: Connection closed by remote host

可以通过加 -v 看到更为详细的信息,

$ ssh -v x.x.x.x
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to x.x.x.x [x.x.x.x] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /home/admin/.ssh/identity type -1
debug1: identity file /home/admin/.ssh/id_rsa type -1
debug1: identity file /home/admin/.ssh/id_dsa type 2
debug1: loaded 3 keys
ssh_exchange_identification: Connection closed by remote host

那么正常的情况是什么样子的呢?

$ ssh -v 10.242.192.2
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.242.192.2 [10.242.192.2] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /home/admin/.ssh/identity type -1
debug1: identity file /home/admin/.ssh/id_rsa type 1
debug1: identity file /home/admin/.ssh/id_dsa type 2
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
Warning: Permanently added '10.242.192.2' (DSA) to the list of known hosts.
debug1: ssh_dss_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/admin/.ssh/identity
debug1: Offering public key: /home/admin/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Offering public key: /home/admin/.ssh/id_dsa
debug1: Server accepts key: pkalg ssh-dss blen 433
debug1: read PEM private key done: type DSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Fri Aug  7 21:02:57 2015 from 10.242.192.1
groups: DEFAULT ALL ALL_OPS GEMCLIENT ALIYUN ECS_ALL AY_DG WEAKPASS ECS_PUB
gemstone: FINISHED at Mon Dec  1 17:12:15 2014
last-working-gemstone: 1417425135 2014-12-01 17:12:15

分析机器是可以ping的通的,但是ssh不上,通过其他方式到机器看了一下机器的load,

>>> ret.stdout
'15:24:55 up 686 days, 21:50,  0 users,  load average: 4483.06, 4429.87, 4288.12
'

发现load实在是太高了,有4000多,这还是第一次看见这么高的load,本来还打算重启一下服务,看来是没辙了,只能,关了机器。

上网上看了出现这种错误,排查的方式

主要角度有:

  • 看 /etc/hosts.allow和/etc/hosts.deny

  • load比较高,导致

原文地址:https://www.cnblogs.com/zk47/p/4725931.html