Server Fault is a question and answer site for system and network administrators. 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 notice my local ~/.ssh/known_hosts file has two entries for the same machine on the local LAN:

 somemachine, ssh-rsa KEY... ssh-rsa KEY...

It's the same key, the second one doesn't have the IP though. Is this just a result of having a search domain and so the known_hosts file must contain the "duplicate" key?

SSH won't detect it is visiting the same machine regardless of the hostname you attempt to connect with? 'SSH' does not request to create a new known_host so could I change the known_host to:

 somemachine,, ssh-rsa KEY...


share|improve this question
See for a discussion on why ssh does not first canonicalize the host name you entered on the command line before checking known_hosts. – Mark Wagner Mar 27 '12 at 16:43
up vote 2 down vote accepted

It is because you must have used ssh somemachine and ssh in the past, which creates 2 different entries. In ubuntu this is how my entries were created, in any case.

share|improve this answer
Right, but does it have to be that way? Updated question – xref Mar 27 '12 at 16:20
yes, you can list all of them in one line. Or you can used somemachine*, if you don't the same hostname in multiple domains. – johnshen64 Mar 27 '12 at 16:33
Beautiful, that works. Thanks Johnshen! – xref Mar 27 '12 at 16:42

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.