现象
 在局域网内,能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
 保存。