SSH slow to login? Disable reverse DNS lookup

By default in Ubuntu (and probably other distributions), when you log into the SSH server, it will do a reverse DNS lookup of the client for security reasons.

That’s fine, but it’s kind of annoying when you don’t have a working reverse DNS for your IP address. Like for all my internal addresses.

To turn it off (thanks to http://ubuntuforums.org/showthread.php?t=577616):

Edit /etc/ssh/sshd_config and add the following line:

UseDNS no

Easy!

3 thoughts on “SSH slow to login? Disable reverse DNS lookup

  1. Just to set the record straight … UseDNS actually doesn’t work for me. I saw this on another forum: add “-u0″ to the sshd command line option. I’ve tried it and it works!.

    Here is the relevant section from the sshd manpage:

    -u len This option is used to specify the size of the field in the utmp
    structure that holds the remote host name. If the resolved host
    name is longer than len, the dotted decimal value will be used
    instead. This allows hosts with very long host names that over-
    flow this field to still be uniquely identified. Specifying -u0
    indicates that only dotted decimal addresses should be put into
    the utmp file. -u0 may also be used to prevent sshd from making
    DNS requests unless the authentication mechanism or configuration
    requires it. Authentication mechanisms that may require DNS
    include RhostsRSAAuthentication, HostbasedAuthentication, and
    using a from=”pattern-list” option in a key file. Configuration
    options that require DNS include using a USER@HOST pattern in
    AllowUsers or DenyUsers.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>