解決 Linux 下 SSH 遠端連線服務卡慢的全過程
連線慢的主要原因是DNS解析導致
解決方法:
1、在ssh服務端上更改/etc/ssh/sshd_config檔案中的配置為如下內容:
UseDNS no # GSSAPI options GSSAPIAuthentication no
然後,執行/etc/init.d/sshd restart重啟sshd程式使上述配置生效,在連線一般就不慢了。
2、如果還慢的話,檢查ssh服務端上/etc/hosts檔案中,127.0.0.1對應的主機名是否和 uname -n的結果一樣,或者把本機ip和hostname(uname -n結果)加入到/etc/hosts裡。
[root@C64 ~]# uname -n C64 [root@C64 ~]# cat /etc/hosts #modi by oldboy 11:12 2013/9/24 127.0.0.1 C64 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.0.0.18 C64 ################
利用ssh -v的除錯功能查詢慢的原因
其實可以用下面的命令除錯為什麼慢的細節(學習這個思路很重要)。
[root@C64 ~]# ssh -v root@10.0.0.19 OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to 10.0.0.19 [10.0.0.19] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/identity type -1 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.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.3 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr 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 The authenticity of host '10.0.0.19 (10.0.0.19)' can't be established. RSA key fingerprint is ca:18:42:76:0e:5a:1c:7d:ef:fc:24:75:80:11:ad:f9. Are you sure you want to continue connecting (yes/no)? yes =======>老男孩老師評:這裡就是提示儲存金鑰的互動提示。 Warning: Permanently added '10.0.0.19' (RSA) to the list of known hosts. 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,password debug1: Next authentication method: publickey debug1: Trying private key: /root/.ssh/identity debug1: Trying private key: /root/.ssh/id_rsa debug1: Trying private key: /root/.ssh/id_dsa debug1: Next authentication method: password root@10.0.0.19's password: =======>老男孩老師評:這裡就是提示輸入密碼的互動提示。 debug1: Authentication succeeded (password). debug1: channel 0: new [client-session] debug1: Entering interactive session. debug1: Sending environment. debug1: Sending env LANG = en_US.UTF-8 Last login: Tue Sep 24 10:30:02 2013 from 10.0.0.18
在遠端連線時如果慢就可以確定卡在哪了。
[root@C64_A ~]# ssh -v oldboy@10.0.0.17 OpenSSH_5.3p1, OpenSSL 1.0.0-fips 29 Mar 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to 10.0.0.17 [10.0.0.17] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/identity type -1 debug1: identity file /root/.ssh/id_rsa type -1 debug1: identity file /root/.ssh/id_dsa type 2 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3 debug1: match: OpenSSH_5.3 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.3 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none debug1: kex: client->server aes128-ctr 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 '10.0.0.17' is known and matches the RSA host key. debug1: Found key in /root/.ssh/known_hosts:2 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-keyex,gssapi-with-mic,password debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug1: Next authentication method: gssapi-with-mic
上述配置沒配就發現卡到gssapi這。就大概知道是gssapi的問題。
實際上在linux系統優化部分就應該優化SSH服務的此處。
相關文章
- [SSH服務]——SSH詳解、常用的遠端連線工具
- 解決SSh連線過慢
- Linux下 SSH遠端管理服務Linux
- 解決ssh連線慢
- 解決:連線遠端redis服務失敗(在linux部署)RedisLinux
- Ssh連線過慢
- SSH 連線慢的解決方案詳解
- ubuntu18.04開啟ssh服務和ssh遠端連線Ubuntu
- 遠端連線Kali Linux使用PuTTY實現SSH遠端連線Linux
- Ubuntu終端ssh連線伺服器慢的解決方法Ubuntu伺服器
- linux 遠端連線ssh錯誤Linux
- SSH 隧道遠端連線
- Windows遠端連線Docker服務WindowsDocker
- SSH遠端連線Linux伺服器Linux伺服器
- SSH服務連線
- ssh遠端連結(簡易連線linux命令)Linux
- Win7無法建立遠端連線管理服務的解決方法Win7
- SSH建立連線的過程
- SSH遠端連線 Linux 伺服器教程Linux伺服器
- Linux網路-ssh遠端連線協議Linux協議
- win10遠端桌面很慢怎麼解決_win10遠端桌面連線慢的解決步驟Win10
- jconsole連線遠端服務
- Liunx開啟ssh遠端連線
- 使用 SSH 遠端連線到 Linux 伺服器Linux伺服器
- Linux下安裝redis資料庫服務,並開啟遠端連線LinuxRedis資料庫
- vnc遠端連線linux,vnc遠端連線linux的具體方法。VNCLinux
- vnc遠端連線linux,vnc遠端連線linux的具體操作VNCLinux
- 使用免費的Oracle雲服務-遠端連線ATPOracle
- 如何利用SSH通道來連線遠端的MysqlMySql
- 遠端連線 Mysql 失敗的解決方法MySql
- 解決mysql不能遠端連線的問題MySql
- win10 如何開啟遠端服務_win10如何開啟遠端連線服務Win10
- CentOS環境下mysql遠端連線和問題解決CentOSMySql
- Ubuntu開啟ssh服務遠端登入Ubuntu
- UltraEdit下ftp配置,UE遠端連線linuxFTPLinux
- ssh連線超時的解決
- win10遠端桌面連線卡如何解決_windows10遠端連線桌面很卡怎麼處理Win10Windows
- Linux 連線遠端桌面Linux