How do I change the SSH Key Fingerprint output type?

Lee Painter

Various parts of the API will output an SSH Key Fingerprint in the form:

2048 MD5:5a:ee:27:55:8c:a4:bd:3e:9e:82:29:da:37:65:fa:9f lee@sshtools.com (RSA)

Fingerprints uniquely identify a public/private key pair and can be used to verify you have the correct public key.

You can generate a key fingerprint from the command line using the command

ssh-keygen -l -f id_rsa

Fingerprints are created using digest algorithms. Previous versions of SSH originally used MD5, and then later SHA1 to generate these. Now the default algorithm is SHA256.

2048 SHA256:lKcvExK0xXxts2LidbtV64f6M/mdGHfi8TubTAtMzJw lee@sshtools.com (RSA)

 

Configure the API to use a specific digest

You can configure the Maverick Legacy APIs to use any of the supported digests as default. This will impact any method that returns a fingerprint, such as SshPublicKey's getFingerprint method.

SshKeyFingerprint.setDefaultHashAlgorithm(SshKeyFingerprint.SHA256_FINGERPRINT);