SSH or SCP is often used to connect to a bunch of remote hosts, which are also Linux Hosts. The speed of creating SSH connections is particularly slow, but the operation speed is normal after the connection is established, it seems that this is not the network reason. The solution is to view the debugging information through the-V parameter of SSH:
Use SSH-V to view the detailed connection establishment process. I immediately tried it on a host that was slow to establish the connection and found it here for the longest time in a lot of output information:
Debug1: authentications that can continue: publickey, gssapi-with-mic, passworddebug1: Next authentication method: gssapi-with-micdebug1: unspecified GSS failure. minor code may provide more informationno credentials cache founddebug1: unspecified GSS failure. minor code may provide more informationno credentials cache founddebug1: unspecified GSS failure. minor code may provide more informationdebug1: Next authentication method: publickey
It turns out that it is a waste of time to open (Remote Server) The gssapi-with-mic authentication method that is meaningless and will fail) /etc/ssh/ssh_config change gssapiauthentication yes to no to turn it off, so that SSH can directly try the wonderful publickey authentication method.
Comparison of the SSH connection time before and after gssapiauthentication is disabled:
View plaincopy to clipboardprint?
[Email protected]: ~ $ Time SSH [email protected] exit
Real 0m18. 488 s
User 0m0. 004 s
Sys 0m0. 008 s
[Email protected]: ~ $ Time SSH [email protected] exit
Real 0m3. 531 s
User 0m0. 016 s
Sys 0m0. 000 s
It is effective whether you disable it on the server or on a local machine. because our servers are managed by dedicated personnel, there is no root account. so I added
Gssapiauthentication No
You can solve the problem.