How to get remote server SSH key SHA256 fingerprints

Recently came across a situation where we needed the SHA256 RSA fingerprint of a remote server.

Here is the command you can use to obtain the key fingerprints:

$ ssh-keyscan testhost.example.com | ssh-keygen -lf -
# testhost.example.com:22 SSH-2.0-OpenSSH_8.7
# testhost.example.com:22 SSH-2.0-OpenSSH_8.7
# testhost.example.com:22 SSH-2.0-OpenSSH_8.7
3072 SHA256:u9OWvd2SrKJtBBhgrwyHOIjNY/buafAxJ60CxuGTr0s testhost.example.com (RSA)
256 SHA256:XCPS0QElv+l0AGO7abDh/hzut6sTOP4BoyenArXTssI testhost.example.com (ECDSA)
256 SHA256:gj4SPnG7tdBRba4XymR30KzJCRxdCiGbFX1IBzeoECk testhost.example.com (ED25519)

You may also like...