I don't want to use -o StrictHostKeyChecking=no option, but I want to save the public key of the server in a file and use this public key on every connection, even IP address or port is changed.When -o UserKnownHostsFile=myfile option is used, ssh still asks for verification if we connect the same machine over a different IP. How to tell ssh to save a public key in a different location and use this public key in current connection? Example usage: # there is no 'foo-public.key' file at this momentssh -o TheMagicalOption=foo-public.key user@example.com -p 1234The authenticity of host 'xxxxxxxx' can't be established.ECDSA key fingerprint is SHA256:LR5wDKrEmHD0QhRcAmxTxBnzWIRmNUfJyeawhKw+W38.Are you sure you want to continue connecting (yes/no)? [YES]# 'foo-public.key' is created at this point on-target $ exit # another port forward is made, so the same server is on port 5678ssh -o TheMagicalOption=foo-public.key user@example.com -p 5678# not asking the same verification questionon-target $     
How to accept SSH Host keys programmatically if fingerprint is known?
ssh