熱搜:win11繞過硬件限制安裝 一鍵重裝Win10系統(tǒng) 最干凈的u盤啟動盤 真正純凈版的win7系統(tǒng)
時(shí)間:2015-04-03 17:05:07 作者:qipeng 來源:系統(tǒng)之家 1. 掃描二維碼隨時(shí)看資訊 2. 請使用手機(jī)瀏覽器訪問: https://m.xitongzhijia.net/xtjc/20150403/44096.html 手機(jī)查看 評論 反饋
ssh在連接其他Linux機(jī)器的時(shí)候,有時(shí)會出現(xiàn)這樣的問題,雖然能夠連接上,但連接速度很慢,非常消耗時(shí)間,下面小編就給大家介紹下ssh連接Linux機(jī)器過慢的解決方法,感興趣的朋友可以來了解下。
在局域網(wǎng)內(nèi),能ping通目標(biāo)機(jī)器,并且時(shí)延是微秒級。
用ssh連局域網(wǎng)內(nèi)其他linux機(jī)器,會等待10-30秒才有提示輸入密碼。嚴(yán)重影響工作效率。
CentOS修改后效果一樣
=================================
客戶端操作系統(tǒng)版本:
cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION=“Ubuntu 9.10”0
=================================
調(diào)試信息:
[root@IBM ~]# ssh -v 10.10.10.100
OpenSSH_3.9p1, OpenSSL 0.9.7a Feb 19 2003
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 10.10.10.100 [10.10.10.100] port 22.
debug1: connect to address 10.10.10.100 port 22: Connection refused
ssh: connect to host 10.10.10.100 port 22: Connection refused
----------------[網(wǎng)絡(luò)上的調(diào)試信息]----------------------
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 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
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
事實(shí)上,正是從gssapi-with-mic這一行開始,開始耗時(shí)間。
失敗的嘗試:
有人說是在目標(biāo)機(jī)器中修改/etc/ssh/sshd_conf文件
將UseDNS 的缺省值由yes修改為no,并重啟sshd。我試了,對這種情況不管用。但不排除對別的延遲情況管用。
====================
有效的解決辦法:
1、修改本地機(jī)器的hosts文件,將目標(biāo)機(jī)器的IP和域名加上去;蛘咦尡緳C(jī)的DNS 服務(wù)器能解析目標(biāo)地址。
vi /etc/hosts
192.168.12.16 ourdev
其格式是“目標(biāo)機(jī)器IP 目標(biāo)機(jī)器名稱”這種方法促效。沒有延遲就連上了。不過如果給每臺都加一個域名解析,挺辛苦的。但在windows下用putty或secure-crt時(shí)可以采用這種方法。
2、修改本機(jī)的客戶端配置文件ssh_conf,注意,不是sshd_conf
vi /etc/ssh/ssh_conf
找到
GSSAPIAuthentication yes
改為
GSSAPIAuthentication no
保存。
再連目標(biāo)機(jī)器,速度就飛快了。
GSSAPI ( Generic Security Services Application Programming Interface) 是一套類似Kerberos 5 的通用網(wǎng)絡(luò)安全系統(tǒng)接口。該接口是對各種不同的客戶端服務(wù)器安全機(jī)制的封裝,以消除安全接口的不同,降低編程難度。但該接口在目標(biāo)機(jī)器無域名解析時(shí)會有問題。我看到有人給Ubuntu提交了相關(guān)bug, 說要將GSSAPIAuthentication的缺省值設(shè)為no,不知為何,ubuntu9.10的缺省值還是yes。
修改完畢,此時(shí)的連接調(diào)試數(shù)據(jù)變?yōu)榱耍?/p>
view plaincopy to clipboardprint?
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 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: 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
password:
上面就是ssh連接Linux過慢的解決方法介紹了,通過本文的方法解決后,連接速度明顯快了不少,大大節(jié)約了時(shí)間。
發(fā)表評論
共0條
評論就這些咯,讓大家也知道你的獨(dú)特見解
立即評論以上留言僅代表用戶個人觀點(diǎn),不代表系統(tǒng)之家立場