在Centos的ssh默认配置安装完成之后,我们会发现ssh登陆服务器的时候会十分缓慢,等待一段时间之后才出现输入密码的情况。大部分时间这种等待还是可以忍耐,但是有些软件使用ssh进行通讯的,可能会有超时的情况,需要进行更改。
1.缓慢的情况有可能是由于DNS的问题造成的
修改/etc/ssh/sshd_config
中UseDNS项,默认注释掉了,但ssh缺省情况下UseDNS的值是yes,我们需要改成no
...
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
...
更改为:
...
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none
...
2.关闭ssh的gssapi认证
同样是修改/etc/ssh/sshd_config
文件,将其中中GSSAPIAuthenticatio项指定GSSAPIAuthenticatio=no
...
# GSSAPI options
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no
...
修改为:
...
# GSSAPI options
GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no
...
3.重启sshd服务
systemctl restart sshd
然后再登陆尝试即可即时登陆输入密码了。