公司开发服务器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只有等到超时才罢休 。。。