The best solution (ie. closest to what I want) I could find is to use the option HostKeyAlias
: it will use an hostname I specify to access known_hosts
(rather than the IP I'm connecting to).
I will need to add the host's public key to known_hosts
using a given hostname (eg: myhost
) and then connect to it using:
ssh -o 'HostKeyAlias myhost' ...