SSH slow to connect? Turn UseDNS off 1

Another quick tidbit I learned when one of my CentOS boxes was slow to connect via SSH. Connection happened quickly when I would connect from a box on the same router, but connecting from my home machine caused a delay of 20-30 seconds each time. The fix was uncommenting this line in /etc/ssh/sshd_config:

#UseDNS yes

and changing it to:

UseDNS no

I believe the delays were being caused by a combination of IPv6 and DNS, but regardless of the cause, that was the fix.

  • Mikael

    Somehow this was the top result for one of my Google searches for this problem, I’m also suspecting that the root cause is something related to IPv6 and DNS.

    Or to be more specific, doing requests for the AAAA record of the client works just fine both over IPv4 and IPv6 so I suspect it’s more a matter of the sshd being stupid in some way…