Fix slow ssh response
When logging into an ssh server you may experience a long delay after authentication, and before you get the prompt. This will happen with most sshd servers on a home network or on a new network while it is being set up.
The reason is that sshd tries to do a reverse lookup on the connecting IP, which takes a while to time out.
To speed up the initial response of ssh, the solution is to prevent these reverse lookups, at least until the network has a working DNS which can resolve the connecting IPs to names. To do this, set "
While searching for this solution, I came across other configuration settings. They didn't apply to my case, but if you still have problems, you may want to set "
Now I have to find an equivalent solution for rsync.
The reason is that sshd tries to do a reverse lookup on the connecting IP, which takes a while to time out.
To speed up the initial response of ssh, the solution is to prevent these reverse lookups, at least until the network has a working DNS which can resolve the connecting IPs to names. To do this, set "
UseDNS no
" in your sshd_config file and force sshd to re-read it's configuration.sudo -s # if you are not root, like on Ubuntu or Mac file=/etc/sshd_config # or file=/etc/ssh/sshd_config # or on a Mac file=/private/etc/sshd_config perl -i.bak -pe 's/^\s*#?UseDNS\s+.*/UseDNS no/i' $file grep -qi 'UseDNS no' $file || echo UseDNS no >> $file # on Linux: kill -HUP `cat /var/run/sshd.pid`(the last kill line to force sshd re-read it's config file doesn't work on Mac)
While searching for this solution, I came across other configuration settings. They didn't apply to my case, but if you still have problems, you may want to set "
GSSAPIKeyExchange no
" in your client configuration file which is usually in /etc/ssh_config (ssh_ , not sshd_ !). Or look into IPv6 problems.Now I have to find an equivalent solution for rsync.
5 Comments:
Thanks for pointing me out to this. Such slow response behaviour doesn't bother me actually that much, but from time to time I've been wondering why some servers response right away while logging to them with SSH-client.
By default reverse DNS lookups are enabled even if "UseDNS yes" is not set for sshd_config file configuration.
Anyway, for me setting "UseDNS no" did the trick.
Thanks! Worked like a champ!
works! thanks
This has been bugging me for over a year, finally solved, thank you!
Me too, this slow ssh had bugged me for such a long time.. awesome tip !
Post a Comment
<< Home