ssh登录慢解决办法

这两天ssh登录局域网的一台服务器非常慢,严重影响工作效率,怎么办?查了一下网上的解决办法,总结一下:

使用命令ssh -v xxx@x.x.x.x

可以看到debug信息,找到问题出在哪:

debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Unspecified GSS failure. Minor code may provide more information


debug1: Unspecified GSS failure. Minor code may provide more information
Cannot determine realm for numeric host address

debug1: Next authentication method: publickey
debug1: Trying private key: /home/szyl/.ssh/identity
debug1: Trying private key: /home/szyl/.ssh/id_rsa
debug1: Trying private key: /home/szyl/.ssh/id_dsa
debug1: Next authentication method: password

发现一直卡在gssapi-with-mic这步,解决方法:

打开(远程服务器) /etc/ssh/sshd_config(注意是文件 /etc/ssh/sshd_config 而不是/etc/ssh/ssh_config),

1、把里面的 GSSAPIAuthentication yes 改成 no;

2、把里面的UseDNS yes 改成 no;

3、/etc/init.d/sshd restart 重启sshd进程使配置生效。

 netstat -a | more 看有没正常启动,如果出现: 

 tcp   0      0 *:ssh         *:*         LISTEN 

 就说明正常启动了。

 大功告成!处理前后建立 ssh 连接时间的对比:

$ time xxx@x.x.x.x

real 0m53.129s
user 0m0.005s
sys 0m0.007s

$ time xxx@x.x.x.x

real 0m1.122s
user 0m0.005s
sys 0m0.004s

so fast!如没能解决你的问题,请参照这篇:http://linux.chinaunix.net/techdoc/net/2008/08/06/1023398.shtml

posted @ 2015-11-06 11:07  arccosxy  阅读(673)  评论(0编辑  收藏  举报