Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I know what it does, but i don't know why. What attack(s) does it prevent ?

Is it relevant for all kind of authentication methods ? (hostbased, password, publickey, keyboard-interactive ...)

share|improve this question
    
I added one to CoreOS also here: github.com/coreos/bugs/issues/92 –  Nayeem Syed Jul 25 at 9:36

4 Answers 4

up vote 17 down vote accepted

The UseDNS option is mostly useless. If the client machines are out there on the Internet, there is a high chance that they don't have any reverse DNS, their reverse DNS doesn't resolve forward, or their DNS doesn't provide any information other than “belongs to this ISP” which the IP address already tells you.

In typical configurations, DNS is only used for logging. It can be used for authentication, but only if IgnoreRhosts no is specified in sshd_config. This is for compatibility with old installations that used rsh, where you can say “the user called bob on the machine called darkstar may log in as alice without showing any credentials” (by writing darkstar bob in ~alice/.rhosts). It is only secure if you trust all the machines that may possibly be connecting to the ssh server. In other words, this is very very rarely usable in a secure way.

Given that the DNS lookup doesn't provide any useful information except in very peculiar circumstances, it should be turned off. As far as I can tell, the only reason it's on by default is that it's technically more secure (if you're concerned about authentication, not availability), even though that only applies to a tiny set of circumstances.

share|improve this answer
    
So, UseDNS is relevant only for hostbased authentication ? If i don't use hostbased auth and i don't care if hostname or IP show up in logs, UseDNS makes no difference ? –  user368507 Nov 28 '12 at 19:24
1  
@user368507 Yes, that's it. UseDNS isn't even useful if you use key-based host authentication, only if you use hostname-based host authentication (i.e. extremely weak authentication). –  Gilles Nov 28 '12 at 19:33

From the manpage of sshd_config(5):

 UseDNS  Specifies whether sshd(8) should look up the remote host name and
         check that the resolved host name for the remote IP address maps
         back to the very same IP address.  The default is “yes”.

Enabling this makes access from a location without proper (forward and reverse) DNS generate a warning in the logs.

So this doesn't prevent any attack except that it would need some qualified remote address of the client in order not to log any warning. Such a warning may help you in tracing down the attacker only if that PTR record makes any sense.

edit: updated according to comment of Andrey Voitenkov.

share|improve this answer
    
So it is a filter on who is allowed to connect based on whatever there is in the DNS server ? –  user368507 Nov 27 '12 at 22:31
2  
Why would it make access impossible? sshd just generates warning if DNS A/PTR records do not match. Logon sequence will be slow in case of resolving problems. –  Andrey Voitenkov Nov 27 '12 at 22:32

It is needed when you use FROM option in an authorized_keys file and you want to filter by names and not just IPs.

The FROM option in a line of an authorized_keys file allows you to limit hosts that can use a specific key.
This increases the ability of managing multiple servers that have access to each other without allowing clones of a machine to impersonate it's origin, usually unintentionally (leftover crontabs, human error).

share|improve this answer

I added to a bug report (old but still current) in Ubuntu about this.

https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/424371

I proposed changing the default to No and adding newer documentation on it:

# UseDNS - Determines whether IP Address to Hostname lookup and comparison is performed
# Default value is No which avoids login delays when the remote client's DNS cannot be resolved
# Value of No implies that the usage of "from=" in authorized_keys will not support DNS host names but only IP addresses.
# Value of Yes supports host names in "from=" for authorized_keys. Additionally if the remote client's IP address does not match the resolved DNS host name (or could not be reverse lookup resolved) then a warning is logged.
share|improve this answer
    
Up up upvote ... this is more useful, because it contains a piece of information I was looking for. –  0xC0000022L May 23 at 17:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.