// you’re reading...

dot.help Lab

Fix slow connections to Ubuntu SSH servers

As of Ubuntu 8.10 and older, connections to SSH servers with default configs can be annoyingly slow. Thisterminal is because the OpenSSH daemon uses DNS to run a reverse lookup on the client to be sure that they aren’t faking their hostname. You can disable most look-ups by implementing the following setting:

As root edit “/etc/ssh/sshd_config” and add the line “UseDNS no“.

This can also be done by running the following command:

sudo echo "UseDNS no" >> /etc/ssh/sshd_config

Sources:

This issue is documented at OpenSSH.org

Fix and more details available at: http://tech.waltco.biz/2008/02/02/ssh-slow-to-connect-in-ubuntu-710-gutsy-gibbon/

Discussion

10 comments for “Fix slow connections to Ubuntu SSH servers”

  1. Thanx, your saved post saved me some hours of trying to find the reason myself.

    Posted by Nudge | April 8, 2010, 8:32 am
  2. On Ubuntu 10.04 (Lucid Lynx), I had a similar problem. I found out that the /etc/ssh/ssh_config (config file for the ssh client) was overriding the defaults with

    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

    I commented out these two lines. Now ssh is not waiting for GSS anymore and the login speed is back to normal.

    Posted by Fred Mora | July 28, 2010, 1:34 pm
  3. It works. Thanks!

    Posted by shining365 | December 2, 2010, 12:28 am
  4. It works for ubuntu 10.10 as well! Thank you!!

    Posted by Skurpi | May 9, 2011, 12:26 am
  5. Good stuff! This DNS trick fixed it up for me.

    Thanks!

    Posted by twig | July 17, 2011, 8:51 pm
  6. Thanks, setting “UseDNS no“ works on my Ubuntu Server 10.04.

    Posted by Etile Ved | December 15, 2011, 5:52 pm
  7. Fred Mora’s tip about GSS config did the trick for me on Ubuntu 11.10, thanks!

    Posted by Kai Carver | January 14, 2012, 12:15 pm
  8. Your sudo command doesn’t work, because the file redirect will be run as the regular user (outside of sudo).

    Here’s what I normally do:

    echo “UseDNS no” | sudo tee -a /etc/ssh/sshd_config

    Posted by Dave | January 20, 2012, 12:35 pm
  9. It work for me, thanks

    Posted by VAN DUC UY | August 13, 2012, 8:05 pm
  10. The sudo used with redircet doesn’t work. Sudo does NOT traverse the redirection, so the only part of the commen you gave which has sudo powers is the echo command (not useful). The command that Dave gave is the correct way to do it. I suggest you ammend the guide. The ONLY way your command will work is if it is ran as root, but then you won’t need sudo at all.

    Posted by ActionParsnip | January 15, 2013, 2:04 am

Post a comment

Advertisement

Categories