SSH串連緩慢問題處理

來源:互聯網
上載者:User

SSH 串連緩慢問題處理

問題現象:
我們有時候會遇到ssh串連伺服器的時候非常慢,經常是要等30秒以上,甚至更長的時間。但是通過telent沒有問題可以實現秒登,ping都沒有問題返回都是幾毫秒。

問題原因:
原因是因為ssh在串連的時候會去尋找DNS記錄進行尋找訪問,那麼這個時候DNS又正好沒有開啟或者說DNS裡面沒有需要sshd訪問的相關記錄,所有DNS在輪訓的時候就會耗費大量的時間。

解決辦法:

1、在伺服器上配置ip及hostname對應解析

2、修改sshd設定檔UseDNS參數,將其禁用即可

3、修改ssh設定檔GSSAPIAuthentication 參數,將其禁用即可

4、修改名稱搜尋優先順序,配置nsswitch.conf檔案

5、重啟sshd服務及network服務

步驟如下:

1、在伺服器上配置ip及hostname對應解析 [root@standby ~]# echo 192.168.7.60 stanby >>/etc/hosts2、修改/etc/ssh/sshd_config檔案,添加如下兩個參數 [root@standby ~]# echo UseDNS=no >>/etc/ssh/ssh_config[root@standby ~]# echo GSSAPIAuthentication no >>/etc/ssh/ssh_config[root@standby ~]#3、修改/etc/nsswitch.conf保證hosts參數files在前面 [root@standby ~]# cat /etc/nsswitch.conf |grep hosts#hosts: db files nisplus nis dnshosts: files dns4、重啟sshd和network服務 [root@standby ~]# service sshd restartStopping sshd: [ OK ]Starting sshd: [ OK ][root@standby ~]# service network restartShutting down interface eth0: [ OK ]Shutting down loopback interface: [ OK ]Bringing up loopback interface: [ OK ]Bringing up interface eth0: [ OK ][root@standby ~]# 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.