ssh-keyscan

Get the public SSH keys of remote hosts. More information: https://man.openbsd.org/ssh-keyscan.

ssh-keyscan host

ssh-keyscan -p port host

ssh-keyscan -t rsa,dsa,ecdsa,ed25519 host

ssh-keyscan -H host >> ~/.ssh/known_hosts