Solve the problem of slow SSH connection (sometimes the password is prompted only half a minute)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.