Tim TrottTim TrottWelcome to my site!

Long Delay After Entering Username via SSH

By , Sunday 16th December 2012 in Linux

For a while now I have been plagued with long delay after entering username each time I log into my Ubuntu server via SSH. Very annoying!

After a bit of Googling I found out that the delay after entering username is caused by the SSH daemon being set to do a reverse DNS lookup to the host connecting to it. A reverse DNS lookup converts the IP address to a host name.

There are two ways to get around this problem. Firstly you can add the client IP and hostname to the host tables, thus preventing a lookup or secondly you can disable reverse DNS lookups altogether.

To Add IP address to host table

On the command line, run:

$ sudo pico /etc/hosts

When prompted enter you password and add an entry for your client IP address and hostname.

127.0.0.1 localhost
192.168.0.2 ubuntu
192.168.0.3 windows7desktop

Save and close the file by pressing Ctrl+O followed by Ctrl+X. Changes should be picked up immediately.

To disable reverse DNS lookups

On the command line, run:

$ sudo pico /etc/ssh/sshd_config

And at the bottom of the file add "UseDNS no" (excluding quotes). Save and exit as described above, then restart the SSH daemon by executing:

$ sudo /etc/init.d/ssh restart

If successful, next time you login you will not have any delay after entering username and password.

My website and its content are free to use without the clutter of adverts, tracking cookies, marketing messages or anything else like that. If you enjoyed reading this article, or it helped you in some way, all I ask in return is you leave a comment below or share this page with your friends. Thank you.

About the Author

Tim Trott

Tim is a professional software engineer, designer, photographer and astronomer from the United Kingdom. You can follow him on Twitter to get the latest updates.

Further Reading
Leave a Reply

Your email address will not be published.