Http://blog.csdn.net/ablo_zhou/article/details/5074887
==================
Symptom:
In the LAN, the target machine can be pinged with a latency of microseconds.
Connect to other Linux machines in the LAN Using SSH. The password will not be prompted until 10-30 seconds. It seriously affects work efficiency.
======================================
Client operating system version:
[Email protected]: ~ $ CAT/etc/LSB-release
Distrib_id = Ubuntu
Distrib_release = 9.10
Distrib_codename = karmic
Distrib_description = "ubuntu 9.10"
======================================
Debugging information:
[CSS] View plaincopy
- [Email protected]: ~ $ Ssh-V 192.168.12.16
-
- Openssh_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
-
- Debug1: Reading configuration data/etc/ssh/ssh_config
-
- Debug1: Applying options *
-
- 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 initialized ed
-
- 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) 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 ed
-
- Debug1: ssh2_msg_service_request sent
-
- Debug1: ssh2_msg_service_accept received ed
-
- 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
-
- [Email protected] 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
The following error message is displayed:
Debug1: Next authentication method: gssapi-with-mic
Debug1: An invalid name was supplied
Cannot determine realm For numeric host address
In fact, it takes time to start from the gssapi-with-mic line.
================================
Failed attempts:
Some people say that the/etc/ssh/sshd_conf file is modified on the target machine.
Change the default value of usedns from yes to no and Restart sshd. I tried it. I don't need to use it in this case. However, it is not ruled out to use other latencies.
================================
Effective Solution:
1. Modify the hosts file of the Local Machine and add the IP address and domain name of the target machine. Or let the local DNS server resolve the target address.
VI/etc/hosts
192.168.12.16 ourdev
The format is "target machine IP address target machine name. Connect without delay. However, it would be hard to resolve each domain name. However, putty or secure-CRT can be used in windows.
2. Modify the local client configuration file ssh_conf. Note that it is not sshd_conf
VI/etc/ssh/ssh_conf
Find
Gssapiauthentication Yes
Change
Gssapiauthentication No
Save.
Connect to the target machine, and the speed will be fast.
Gssapi (Generic Security Services Application Programming Interface)Is a set of universal network security system interfaces similar to Kerberos 5. This interface is encapsulated by different client server security mechanisms to eliminate different security interfaces and reduce programming difficulty. However, this interface may cause problems when the target machine does not have domain name resolution. I see someone submitted a bug to Ubuntu, saying that we want to set the default value of gssapiauthentication to No. Somehow, the default value of ubuntu9.10 is yes.
After modification, the connection debugging data changes:
[C-sharp] View plaincopy
-
- [Email protected]: ~ $ Ssh-V 192.168.12.16
-
- Openssh_5.1p1 Debian-6ubuntu2, OpenSSL 0.9.8g 19 Oct 2007
-
- Debug1: Reading configuration data/etc/ssh/ssh_config
-
- Debug1: Applying options *
- 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 initialized ed
-
- 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) 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 ed
-
- Debug1: ssh2_msg_service_request sent
-
- Debug1: ssh2_msg_service_accept received ed
-
- Debug1: authentications that can continue: publickey, gssapi-with-mic, password
- 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
-
- [Email protected]'s password:
Solution to slow SSH connection