Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukaszpiwko/e2d1609dca2f036ba067227e4dc9e82e to your computer and use it in GitHub Desktop.
Save lukaszpiwko/e2d1609dca2f036ba067227e4dc9e82e to your computer and use it in GitHub Desktop.
Verifying AWS EC2 Key Pair's Fingerprint

If you created your key pair using AWS, you can use the OpenSSL tools to generate a fingerprint as follows:

$ openssl pkcs8 -in path_to_private_key -inform PEM -outform DER -topk8 -nocrypt | openssl sha1 -c

If you created a key pair using a third-party tool and uploaded the public key to AWS, you can use the OpenSSL tools to generate the fingerprint as follows:

$ openssl rsa -in path_to_private_key -pubout -outform DER | openssl md5 -c

If you created an OpenSSH key pair using OpenSSH 7.8 or later and uploaded the public key to AWS, you can use ssh-keygen to generate the fingerprint as follows:

$ ssh-keygen -ef path_to_private_key -m PEM | openssl rsa -RSAPublicKey_in -outform DER | openssl md5 -c

Reference: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#verify-key-pair-fingerprints

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment