Solve the problem of slow ssh connection in Linux-Debian information of Linux release technology. The following is a detailed description. For ssh to remote hosts, it is normal to slow down because of many factors such as the speed of the network. However, if ssh to a local host, it will take about 30 seconds, it's a bit intolerable!
This problem has existed since debian (lenny, which was previously used in ubuntu6.06), but it has never been solved (or has been tried, but failed.) Today, I finally couldn't help it. I went to debian mailing-list to ask, and then I got some conclusions based on my own practices!
According to the posts posted on the Internet and the suggestions made by netizens, it seems that the solution to this problem is not universal. But it doesn't matter. There are just a few modifications involved. If you encounter similar problems, you should try to find a solution!
My problem: ssh lan_host. It takes at least 30 seconds to see the Password Input prompt (this is caused by reverse dns lookup on the Internet );
My solution: You need to modify two configuration files:/etc/resolv. conf and/etc/nsswitch. conf.
In/etc/resolv. in the conf file, configure a dns address. The original dns address is 192.168.1.1. There is no problem with accessing the internet, but you need to change it to a dns address similar to 222. xx. xx. xx domain name; (I have not studied the domain name and do not know how to correctly express it)
For/etc/nsswitch. conf: Replace "hosts: files mdns4_minimal [NOTFOUND = return] dns mdns4" with "hosts: files dns". This modification is equivalent to disabling the use of mdns, instead, only dns is used for resolution;
Restart the sshd service.
Mdns: it is mainly used to solve the zeroconf problem. It is generally used to resolve the host name in the LAN. In linux, each host runs an mdns daemon and returns its host name when querying the client. For example, if your host name is abc. if mdns resolution is configured in the conf file, you can ping abc. local, ssh abc. to access the machine. In fact, it is actually gethostbyname that reads nsswitch. conf and then calls the corresponding implementation to obtain the address. It does not need to be configured. (For more details, see: http://www.multicastdns.org /)
The common solution to this problem on the internet is (mainly to modify the configuration file/etc/ssh/sshd_config ):
(1) modify the value of "UseDNS" to "no" (add this configuration option without commenting out). This modification does not seem to work in my system!
(2) modify the value of "GSSAPIAuthentication" to "no" (add this configuration option if not, just release the comment );
In fact, you can run "ssh-v host" on your own for debugging. The debug information shows where the connection is delayed. My test is in "debug1: Unspecified GSS failure. minor code may provide more information "this pause for a while, so I feel that modifying the value of" GSSAPIAuthentication "should be effective, but it turns out that if you do not change the above items, this change still does not work in my system!
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