王高利:Linux__ssh连接缓慢,解决方法如下

ssh -v 192.168.1.138

然后会出现很多bug

例如:

debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found
debug1: Unspecified GSS failure.  Minor code may provide more information
debug1: Unspecified GSS failure.  Minor code may provide more information
Credentials cache file '/tmp/krb5cc_0' not found
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity

查看一下连接时间:

time  ssh [email protected] exit
real0m4.785s
user0m0.014s
sys0m0.011s


1、关闭DNS反向解析

在linux中sshd 的服务里是默认开启DNS解析的。会消耗时间,所以需要关闭。

vim /etc/ssh/sshd_config
UseDNS no

虽然是被注释掉的,但是默认是yes开启的。

time ssh [email protected] exit
real0m3.978s
user0m0.016s
sys0m0.010s


看实际的连接时间明显减少了很多。说明起了作用!


2、关闭SERVER的认证

在authority过程中,gssapi-with-mic有可能出现很大问题,因此关闭gssapi可以提高很大的速度。

vim /etc/ssh/sshd_config
GSSAPIAuthentication no

保存推出

time ssh [email protected] exit
real 0m3.832s
user 0m0.011s
sys  0m0.004s

时间明显减少了很多。基本上就可以正常使用了。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章