Get the fingerprint of an existing SSH public key

Solution 1:

In recent versions of ssh-keygen, one gets an RSA public key fingerprint on Unix-based systems with something like:

$ ssh-keygen -l -E md5 -f ~/.ssh/id_rsa.pub

where the path refers to a public key file.

Solution 2:

Install openssh and openssl packages which contain the commands.

# get the SHA256 and ascii art    
ssh-keygen -l -v -f /path/to/publickey

# get the MD5 for private key
openssl pkey -in /path/to/privatekey -pubout -outform DER | openssl md5 -c

# get the MD5 for public key
openssl pkey -in /path/to/publickey -pubin -pubout -outform DER | openssl md5 -c