Because many people reflect the company test environment Server SSH connection is very slow, to troubleshoot the ping does not drop packets, that is the problem of system configuration. Search on the Internet, the results are very practical.
First, the cause of the investigation
Before testing :
Ssh-v 192.168.1.138
Then there will be a lot of bugs
For example:
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
Check the connection time:
Time ssh [email protected] Exit
Real0m4.785s
User0m0.014s
SYS0m0.011s
Second, configuration optimization
1. Turn off DNS reverse resolution
In Linux, the SSHD service is turned on by default for DNS resolution. It consumes time, so it needs to be closed.
Vim/etc/ssh/sshd_config
Usedns No
Although it is commented out, the default is yes.
Time ssh [email protected] Exit
Real0m3.978s
User0m0.016s
SYS0m0.010s
See the actual connection time significantly reduced a lot. The explanation played a role!
2. Turn off authentication for server
During the authority process, gssapi-with-mic can be a big problem, so shutting down the GSSAPI increases the speed.
Vim/etc/ssh/sshd_config
Gssapiauthentication No
Save launch
Time ssh [email protected] Exit
Real 0m3.832s
User 0m0.011s
SYS 0m0.004s
The time was significantly reduced by a lot. Basically, it can be used normally.
This article from "The Dark before Dawn" blog, declined reprint!
SSH connection Slow