公司開發服務器66,用ssh登陸時很慢,密碼驗證大約有二十幾秒,我記得以前不是這個樣子的。
查找資料後,昭大瞭解決方案:
vi /etc/ssh/sshd_config
找到
#UseDNS yes
取消註釋並改爲no即可
重新啓動ssh
service sshd restart
問題解決。
原因摘自網上:
Its your /etc/resolv.conf
i bet if u go to the comp in a web browser its instant, yeah? why? because your PC doesnt do a reverse DNS lookup on ur IP then... when u telnet/ftp into ur linux box, it'll do a dns lookup on you, to see who you are, if u either correct the settings in the
/etc/resolve.conf file, or just back it up, then delete the contents all together, it should be fine !
大意是登陸時會根據/etc/resolv.conf中指定的dnsserver進行dns查找。
正常情況下該操作會很快結束,但是最近公司加了上網限制,局域網電腦必須在路由上註冊自己的mac纔可以上網。66服務器沒有在路由上註冊mac地址,不能上互聯網,所以linux只有等到超時才罷休 。。。