ssh连接经常超时和ssh连接很慢的原因分析及解决方法

ssh远程连接有几台机器一直很慢,今晚特么的实在忍受不了,决定看一下。

要知道为什么连接很慢,有个-v参数可以打出debug信息(该参数也可以是-vvv,会更详细一点,貌似其它有些应用也会用-v参数作为debug参数),对帮助问题很有用。

大概类似这样的代码:

Are you sure you want to continue connecting (yes)? yes
Warning: Permanently added '192.168.16.34' (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,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/admin/.ssh/identity
debug1: Trying private key: /home/admin/.ssh/id_rsa
debug1: Offering public key: /home/admin/.ssh/id_dsa
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: password
其中在debug1: Offering public key: /home/admin/.ssh/id_dsa这一段后卡了好一会,网上搜索一下,大概是DNS解析耗时,查看配置文件/etc/ssh/sshd_config,将UseDNS设置为no即可。

网上也有说是GSSAPIAuthentication造成的。

GSSAPIAuthentication表明是否启用基于GSSAPI的认证方式,你可以设置no关闭。GSSAPI是通用安全服务应用程序接口,相当于是一种安全事务规范。

我做的比较狠,直接全部:

UseDNS no

GSSAPIAuthentication no

如果没有就自己加上,有就修改下,

搞完之后 /etc/init.d/sshd restart 重启一下,尼玛,现在速度棒棒哒了。。

关键词: ssh连接很慢 , ssh连接超时

上一篇: Linux服务器挂载新硬盘,Linux系统分区和挂载的方法
下一篇: 随手搞的采集某政府信息网的table表格数据

目前还没有人评论,您发表点看法?
发表评论

评论内容 (必填):