关于SSH的一些tricks

时间:2020-12-09 20:57:35

改善SSH登录速度

登录慢的原因有很多, 慢的症状也很多, 有些是出login慢, 有些是出password慢, 有些是输入完password后进提示符慢, 根据 http://superuser.com/questions/166359/top-causes-of-slow-ssh-logins 里面分析, 主要有如下几个手段:

1. 首先, 可以使用 -v 参数, 查看ssh过程输出的debug信息, 从这些输出中很容易找到问题所在

2. 禁用UseDNS, Try setting UseDNS to no in /etc/sshd_config or /etc/ssh/sshd_config

3. 禁用GSSAPIAuthentication, Just add GSSAPIAuthentication no to /etc/ssh/sshd_config on the server and restart the service, 对于这个, 也可以通过设置客户端的配置解决

vi $HOME/.ssh/config
(Note: you would have to create the directory $HOME/.ssh if it does not exist) And add:
Host *
GSSAPIAuthentication no
GSSAPIDelegateCredentials yes

4. 可能是IPv6引起的问题, 可以通过 -4 参数强制使用 IPv4. ssh with the -4 option: ssh -4 me@myserver.com