How to make ssh match known_hosts to host/ip:port instead of just host/ip?

Posted by Prody on Server Fault See other posts from Server Fault or by Prody
Published on 2010-05-13T15:35:35Z Indexed on 2010/05/13 15:44 UTC
Read the original article Hit count: 164

Filed under:

I have two machines behind a firewall, with the ssh ports forwarded to 2201 and 2202.

When I
ssh host -p 2201
it asks if I trust the machine, I say yes, it gets added to ~/.ssh/known_hosts

Then I
ssh host -p 2202
it doesn't let me, because there's already a known_host for this IP in ~/.ssh/known_host:1
(the file was empty when I started, so line 1 is the one added by the previous ssh run)

This happens on CentOS 5.4.

On other distros (I've tried Arch), it appears that ssh matches the knwown_hosts to the ports too, so I can have multiple fingerprints for multiple ports on the same host/ip without any problems.

How can I get this same behavior for CentOS?

I couldn't find anything in man ssh_config.
(or at least not without disabling fingerprint checking)

© Server Fault or respective owner

Related posts about ssh