Skip to main content

Get the public ssh keys of remote hosts.

# To retrieve all public ssh keys of a remote host:
ssh-keyscan <host>

# To retrieve all public ssh keys of a remote host listening on a specific port:
ssh-keyscan -p <port> <host>

# To retrieve certain types of public ssh keys of a remote host:
ssh-keyscan -t <rsa,dsa,ecdsa,ed25519> <host>

# To manually update the ssh known_hosts file with the fingerprint of a given host:
ssh-keyscan -H <host> >> ~/.ssh/known_hosts