SSH连接非常慢解决方法
2016-08-03 00:00
SSH连接非常慢解决方法
2016-08-03
现象
在局域网内,能ping通目标机器,并且时延是微秒级。
用ssh连局域网内其他linux机器,会等待10-30秒才有提示输入密码。严重影响工作效率。
原因
使用ssh –v,打开调试信息:
zhouhh@zhhofs:~$ ssh -v 192.168.12.16
on data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.12.16 [192.168.12.16] port 22.
debug1: Connection established.
debug1: identity file /home/zhouhh/.ssh/identity type -1
debug1: identity file /home/zhouhh/.ssh/id_rsa type -1
debug1: identity file /home/zhouhh/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2
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
debug1: Host '192.168.12.16' is known and matches the RSA host key.
debug1: Found key in /home/zhouhh/.ssh/known_hosts:1
debug1: ssh_rsa_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,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
debug1: An invalid name was supplied
debug1: Next authentication method: publickey
debug1: Trying private key: /home/zhouhh/.ssh/identity
debug1: Trying private key: /home/zhouhh/.ssh/id_rsa
debug1: Trying private key: /home/zhouhh/.ssh/id_dsa
debug1: Next authentication method: password
zhouhh@192.168.12.16's password:
debug1: Authentication succeeded (password).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = zh_CN.UTF-8
Last login: Fri Dec 25 13:35:04 2009 from 192.168.11.146
可以看到如下的错误信息:
debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
事实上,正是从gssapi-with-mic这一行开始,开始耗时间。
解决方法
1.修改本地机器的hosts文件,将目标机器的IP和域名加上去。或者让本机的DNS 服务器能解析目标地址。
vi /etc/hosts
2.修改本机的客户端配置文件ssh_conf,注意,不是sshd_conf
vi /etc/ssh/ssh_conf
找到 GSSAPIAuthentication yes
改为 GSSAPIAuthentication no
保存。