ssh, accept two key fingerprints for the same server IP
Your problem is that host keys are just that, they are a key for the host. There is really only supposed to be one per host. Of course there are several because there are several types of key, but I would avoid relying on key types to give you multiple acceptable keys for a single host.
On the server side
My first suggestion is that you consider carefully if you really want to do this on the client side. You could treat these two OS as the same host and simply copy the host key from one to the other.
If you copy /etc/ssh/ssh_host*
from OpenSSH you can use these on other operating systems. Although they might need some reformatting depending on the SSH server you run.
But ...
May I ask why you have ruled out server side solutions?. Wouldn't the easiest way be to try to make both OS use the same host key? – Philip Couling
@PhilipCouling Partly for ease of use: one of the OSs is Windows. Partly to not transfer keys from a host to another, which is a sometimes discouraged practice. But the main reason is: I would like to obtain some degree of flexibility in ssh client configuration, if it is possible. – BowPark
I think that what you are looking for is a way to treat the two OS as different hosts even though they share an IP and port number.
On the client side
Perhaps the most reliable way will be to set host specific configuration for each OS. Edit (or create) ~/.ssh/config
to add:
Host windows.dualbootbox
Hostname 192.168.10.20
UserKnownHostsFile ~/.ssh/windows.dualbootbox.known_hosts
Host ubuntu.dualbootbox
Hostname 192.168.10.20
UserKnownHostsFile ~/.ssh/ubuntu.dualbootbox.known_hosts
You don't need to specify Hostname
if each Host
already resolves to an IP. See man ssh_config
for more configuration options.
With the above configuration you can then either:
ssh [email protected]
ssh [email protected]