What does a public key extractor do?
A private key always contains enough information to compute its public key. That is why you can lose a .pub file and still get it back. Other times you have a private key in one format, and a tool wants the public half in another: an OpenSSH line for authorized_keys, a PEM block for a library, or a PKCS#1 block for an old RSA application.
This page reads a private key and shows the matching public key in every format it can. It understands OpenSSH private keys, PEM PKCS#8 (also encrypted ones), PKCS#1 RSA and SEC1 EC keys, for RSA, ECDSA (P-256, P-384, P-521) and Ed25519. If you paste a public key instead, as an OpenSSH line, PEM SPKI or PKCS#1, it recognises that and converts it to the other formats. The result includes the key type and size, plus the SHA256 and MD5 fingerprints, so you can confirm that a public key belongs to a given private key.
The work happens in your browser and the key is not uploaded. Still, avoid pasting a private key that guards something real into any website. If you only need to publish the public half, a key made for testing is the safest thing to paste.
How to get a public key
- Paste the key into Private or public key:. It can be a full block starting with
-----BEGIN ...or an OpenSSH key. To try the page first, press Make a sample key. - If the key is encrypted, the page asks you to type its password: fill in Passphrase (only if the key is encrypted):. Leave it empty otherwise.
- Read the line with the type and size, for example an Ed25519 or RSA key and its bits.
- Copy what you need: OpenSSH line (authorized_keys):, PEM SubjectPublicKeyInfo (openssl pkey -pubout): or, for RSA, PEM PKCS#1 RSA PUBLIC KEY:.
- Compare Fingerprint SHA256: with the one your server or Git host shows.
Examples
Recover a lost .pub file
You have id_ed25519 but not id_ed25519.pub. Paste the private file. The OpenSSH line that appears is the content of the missing .pub file, apart from the comment, which a private key can keep or lose.
Give a library the format it wants
A JavaScript or Java library asks for a PEM public key. Take the PEM SubjectPublicKeyInfo block, which begins with -----BEGIN PUBLIC KEY-----. Python and Go libraries use it too. For an RSA key, a library that wants -----BEGIN RSA PUBLIC KEY----- takes the PKCS#1 block.
Check that two files are a pair
Paste the private key and note the SHA256 fingerprint. Paste the public key you were given and compare. If the fingerprints differ, they are not a pair, and the server will refuse the login.
Convert only a public key
Paste an OpenSSH public line. The page tells you the text was already a public key and shows it in the other formats. An Ed25519 key has no PKCS#1 form, so only the OpenSSH and SPKI results appear for it.
Common mistakes
- "This does not look like a key. Paste a PEM block (-----BEGIN ...) or an OpenSSH key." The text is not a key. Include the BEGIN and END lines.
- "The key text is damaged: part of it is missing or changed. Copy it again." Lines were cut or edited, or the Base64 was changed by an email program.
- "The key ends too early. Copy the whole block, including the END line." The paste stopped before the END line.
- "This key is encrypted. Type its passphrase below." Fill in the passphrase field.
- "The passphrase is wrong for this key." Check the passphrase and the keyboard layout.
- "This file holds more than one key. Paste one key at a time."
- "This old-style encrypted PEM key is not supported." Convert it first with
openssl pkcs8 -topk8 -in key.pem -out key-pkcs8.pem. - Unsupported cipher, key type or curve. Only Ed25519, ECDSA P-256, P-384, P-521 and RSA are handled.
Frequently asked questions
Can a public key reveal the private key?
No. Deriving the public key from the private one is easy, but going the other way is computationally infeasible for the key types here. That is why the public key is safe to share.
Why is there no comment in the OpenSSH line?
The comment is just a label and is not part of the key. If the private file does not carry one, the line has none. You can add any label you want after the key.
Are the fingerprints the same as in ssh?
Yes. The SHA256 value matches ssh-keygen -lf, written as SHA256: plus Base64. The MD5 form is the older colon-separated style some systems still show.
How do I make a new key pair?
Use the SSH key generator. To use a key to sign or encrypt, open sign and encrypt with a public key. For an RSA pair in PEM only, see the RSA key pair generator.
Equivalent commands
# OpenSSH private key -> public line
ssh-keygen -y -f ~/.ssh/id_ed25519
# PEM private key -> PEM SubjectPublicKeyInfo
openssl pkey -in key.pem -pubout
# RSA: PEM public key in PKCS#1 form
openssl rsa -in key.pem -RSAPublicKey_out
# Fingerprint
ssh-keygen -lf ~/.ssh/id_ed25519.pub