Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have my DNS search path set to ".intranet", ie, /etc/resolv.conf contains:

search intranet

When I SSH to a host using a FQDN, like "mailserver.intranet", it adds an entry for "mailserver.intranet" to ~/.ssh/known_hosts. If I later SSH to this same host but using the simple "mailserver" name, SSH adds another entry to known_hosts for "mailserver".

Is it possible to make SSH always use FQDN in known_hosts to avoid this duplicity?

share|improve this question
up vote 5 down vote accepted

You could use aliases for host keys:

Host <hostname>*
    hostname    <fqdn>
    HostKeyAlias    <alias>

Your key will be saved to known_hosts as "alias" instead of "hostname" either short or long, the downside is you have to write an entry for each one of your hosts.

Please note the '*' after the hostname at the first line, it's needed for matching both the short and long hostname.

share|improve this answer

Your Answer


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.