Skip to content
TURNKEYGNU / LINUX
AppsDocumentationBlogScreenshotsGitHubTurnKey Hub
文English
EnglishDeutschEspañol日本語Português中文
Home/Blog/SSH session slow to start? It's the DNS stupid!

From the project

SSH session slow to start? It's the DNS stupid!

By Liraz SiriMarch 8, 20102 min read
sshadmin

Ever tried logging into a machine with ssh and found you have to wait much longer than reasonable for the session to start? This happened to me a few times and was especially annoying with machines on my local network (or a VM attached to a virtual network) that should be letting me in immediately.

I eventually got mad enough to strace the SSH daemon and debug what was going on and it turns out it's a DNS thing. Basically the session is slow to start because the SSH server is trying to lookup the hostname of the SSH client and for whatever reason it's timing out (e.g., it can't reach a nameserver, because you happen to be offline)

There are a couple of very simple ways to fix that:

  • add "UseDNS no" to /etc/ssh/sshd_config
  • add the client's net address to the server's /etc/hosts

Was that helpful? Has this ever happened to you? Post a comment!

Comments (2)

Glad I could help!

Reply 1 2010-03-29
Occasionally I wonder whether anyone is finding these blog posts useful. Getting positive feedback is a big encouragement. Oh and sorry for the late reply, I've been monking out offline working on some new stuff!

This worked for me!

Reply 2 2010-03-16

Hi Liraz, thank you. I was having troubles to access through SFTP to my LAMP appliance installed on Virtualbox on my PC, and the problem was solved when I added "UseDNS no" to /etc/ssh/sshd_config.

(we recently configure a domain on our LAN with a Windows 2003 server)

Great! best regards,

Keep exploring

Find your next server

Browse ready-to-use appliances by the job you need to do.

Explore the app library
TURNKEYGNU / LINUX

Own your infrastructure without starting from scratch.

Explore TurnKey
AboutDocumentationFAQBlogGitHub
Free and open sourceSecure by defaultReady to deploy