ssh登录很慢,登录上去后速度正常问题的解决方法

时间:2022-12-10 04:35:22
1. DNS反向解析的问题
OpenSSH在用户登录的时候会验证IP,它根据用户的IP使用反向DNS找到主机名,再使用DNS找到IP地址,最后匹配一下登录的IP是否合法。如果客户机的IP没有域名,或者DNS服务器很慢或不通,那么登录就会很花时间。

解决办法:
只需修改/etc/ssh/sshd_config,设置UseDNS为no即可:
sed -i "s/#UseDNS yes/UseDNS no/"  /etc/ssh/sshd_config
2. gssapi的问题
用ssh -v user@server 可以看到登录时有如下信息:
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
解决办法:
可以使用ssh  -o GSSAPIAuthentication=no user@server登录
也可以修改/etc/ssh/ssh_config,设置GSSAPIAuthentication no
 
最后/init.d/sshd restart/init.d/sshd restart