When getting a message like the following, how can I view the key of the server?
$ ssh example.com
Warning: the ECDSA host key for 'example' differs from the key for the IP address '10.0.0.2'
Offending key for IP in /Users/louis/.ssh/known_hosts:1
When doing ssh -v example.com
I can see debug1: Server host key: ecdsa-sha2-nistp256 SHA256:...
, but this is not the same as the ssh-rsa key eventually stored in known_hosts after correcting the problem.
Best Answer
One pretty easy way is to use ssh-keyscan. This command will request keys from the remote server. For example if I wanted the rsa, ecdsa, and ed25519 host keys from demo.example.org I might use this command.
If you wanted the hashed versions and wanted to append them to your known_hosts you could use a command like this.