SSH service remote access to Linux Server login is slow

Source: Internet
Author: User
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... Vietcsshsshd_config disable ssh dns anti-resolution and add the following line: UseDNSno ※although [U

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)

######################################## #####################


I checked related information online: Workshop

There is a file/etc/nsswitch. conf on the target server, which contains the following line:
Hosts:FileS dns
This line indicates the domain name resolution order of the accessed host. It is to first access the file, that is, the/etc/hosts file. If the hosts does not record the domain name, it will access dns, for domain name resolution, if the dns cannot be accessed, it will wait for the access timeout to return, so the wait time is relatively long. If this line is blocked, can it achieve the same effect? Yes, but if the host needs to access other servers through the domain name, it will certainly not be accessible, so this line should be retained. This problem also reminds us of some side effects of dns unavailability.

I believe many of my friends have abandoned te for security reasons when using Linux.LnEt rlogin or X-window, and openssh is used as the default remote logon method. However, it is often the case thatTelnetIt is fast to the server, but the ssh connection is slow. It takes about half a minute or longer.PingThe speed is also very good, people mistakenly think that the ssh connection is not good. The most common reason for solving this problem is that the server's sshd will go to the DNS to find the hostname for accessing clientIP. If the 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 in the/etc/ssh/sshd_config file on the server (this method has been tried and is easy to use)
3. Comment out/etc/resolv. all rows in conf (for this method, although the configuration file sshd_config is not modified by the other server according to method 2, it is resolv on this server. conf is empty, which means this method is also useful)
4. Modify hosts in/etc/nsswitch. conf on the server to hosts: files.
5. reboot server to make the configuration take effect

######################################## #####################

Related Article

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.