Slow ssh connection establishment

Source: Internet
Author: User
Tags ssh

Ssh/scp is a common command. It is found that the speed of establishing a connection over ssh is very slow for some hosts, but the operation speed is normal after the connection is established.

Use ssh-v to view the detailed connection establishment process:

Debug1: Authentications that can continue: publickey, gssapi-with-mic, password
Debug1: Next authentication method: gssapi-with-mic
Debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
Debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
Debug1: Unspecified GSS failure. Minor code may provide more information
Debug1: Next authentication method: publickey

It turns out that it is a waste of time to try the gssapi-with-mic authentication method. Open/etc/ssh/ssh_config and change GSSAPIAuthentication yes to no to disable it.

If the above solution cannot be solved, we can proceed with troubleshooting.

The most common reason for solving this problem is that the server's sshd will go to DNS to find access.
The hostname of the client IP address. If DNS is unavailable or there are no relevant records, it will take a lot of time.

1. Add the ip address and hostname of your local machine to the/etc/hosts file on the server.

2. Modify or add UseDNS = no to the/etc/ssh/sshd_config file on the server. In addition, problems may also occur in authentication gssapi-with-mic, modify GSSAPIAuthentication no in the/etc/ssh/sshd_config file on the server.


3. Modify hosts in/etc/nsswitch. conf on the server to hosts: files

4. reboot server to make the configuration take effect

/Etc/init. d/sshd restart the sshd process to make the configuration take effect.


The project team's server remotely accesses the Linux server through the SSH service. It is always waiting for a long time to log on.


Try the following method, and then remotely access the Linux server through the SSH service, and instantly log on... Very happy...


Vi/etc/ssh/sshd_config


Disable ssh dns anti-resolution and add the following line:


UseDNS no


※Although [UseDNS yes] in the configuration file is commented out,


But the default switch is yes... (DNS reverse resolution is enabled by default in the SSH service)

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.