RSA Key Pair Generator

New

Generate RSA public and private keys locally in your browser. Choose a key size of 2048, 3072 or 4096 bits and export the key pair as PEM (PKCS#8 or PKCS#1) or in OpenSSH format, ready to copy or download. Keys are created with your browser's Web Crypto API and never leave your device.

Download public-key.pem

Keep the private key secret. Anyone who has it can sign as you or decrypt data meant for you. The key is not encrypted with a passphrase.

Download private-key.pem

How to generate an RSA key pair

  1. Choose a key size. 3072 bits is a good default.
  2. Choose a format: PEM for OpenSSL and most programming libraries, or OpenSSH for SSH logins.
  3. For OpenSSH, optionally enter a comment, such as your email or computer name, to recognise the key later.
  4. Select Generate key pair.
  5. Copy or download the public key and the private key.

You can change the format after generating: the same key pair is shown in the new format, without generating a new one. Reloading the page discards the key.

Which format should I choose?

Format Private key starts with Public key starts with Use it for
PEM (PKCS#8 / SPKI) -----BEGIN PRIVATE KEY----- -----BEGIN PUBLIC KEY----- OpenSSL, Node.js, Python, Java, JWT (RS256) libraries and most modern software
PEM (PKCS#1) -----BEGIN RSA PRIVATE KEY----- -----BEGIN RSA PUBLIC KEY----- Older software that expects the traditional RSA-only format
OpenSSH -----BEGIN OPENSSH PRIVATE KEY----- ssh-rsa AAAA… SSH logins: ~/.ssh/id_rsa and authorized_keys

PKCS#8 and PKCS#1 contain the same key; only the wrapper differs. ssh-keygen also accepts PEM private keys, but the OpenSSH format is what it creates by default.

Which key size should I choose?

Key size Security Notes
2048 bits About 112-bit security The minimum for new keys. NIST considers it acceptable until 2030.
3072 bits About 128-bit security Recommended for keys used beyond 2030. The ssh-keygen default.
4096 bits Above 128-bit security Slower to generate and use, for little practical gain over 3072 bits.

All keys use the standard public exponent 65537.

Using the key for SSH

  1. Choose OpenSSH and generate the key pair.
  2. Save the private key as ~/.ssh/id_rsa and the public key as ~/.ssh/id_rsa.pub.
  3. On Linux and macOS, restrict the private key, or SSH refuses to use it:
chmod 600 ~/.ssh/id_rsa
  1. Add the public key to the server, in ~/.ssh/authorized_keys, or with ssh-copy-id:
ssh-copy-id -i ~/.ssh/id_rsa.pub user@server
  1. Check the fingerprint against the one shown under the public key:
ssh-keygen -lf ~/.ssh/id_rsa.pub

For new SSH keys, Ed25519 is usually a better choice than RSA: shorter keys, faster, and supported by all current SSH servers. Generate one with ssh-keygen -t ed25519. RSA remains useful when a server or device only accepts RSA.

Checking a PEM key with OpenSSL

# Check the private key and show its size
openssl pkey -in private-key.pem -noout -text | head -n 1

# Derive the public key from the private key; it should match public-key.pem
openssl pkey -in private-key.pem -pubout

# Convert a PKCS#1 private key to PKCS#8
openssl pkcs8 -topk8 -nocrypt -in rsa-private-key.pem -out private-key.pem

Security considerations

  • Keys are generated on your device. The tool uses the Web Crypto API's secure key generation in your browser. Keys are not sent to a server or saved.
  • The private key is not passphrase-protected. Store it securely, or add a passphrase after downloading, for example with ssh-keygen -p -f ~/.ssh/id_rsa or openssl pkey -in private-key.pem -aes256 -out encrypted-key.pem.
  • Never share the private key. Only the public key goes to servers, colleagues or certificate requests.
  • For high-value keys, generate them where they will be used. Keys for production servers, certificate authorities or code signing are best created with ssh-keygen, OpenSSL or a hardware security module on the machine that needs them.

Frequently asked questions

Are the keys sent to a server?

No. The key pair is generated by your browser's Web Crypto API and exists only on this page. Nothing is uploaded or saved, and reloading the page discards the key.

What is the difference between the public key and the private key?

The public key can be shared freely: it is used to verify signatures and encrypt data. The private key must stay secret: it creates signatures and decrypts data. Each public key works only with its own private key.

What is the difference between PKCS#1 and PKCS#8?

Both hold the same RSA key. PKCS#1 is an RSA-only format with the header BEGIN RSA PRIVATE KEY. PKCS#8 is a general format for any key type, with the header BEGIN PRIVATE KEY, and is the default in current OpenSSL.

Can I use these keys for JWT signing (RS256)?

Yes. Use the PEM (PKCS#8 / SPKI) format: most JWT libraries load the private key to sign tokens and the public key to verify them.

Is 2048-bit RSA still secure?

Yes, for now. NIST considers 2048-bit RSA acceptable until 2030. For keys that need to stay secure longer, choose 3072 bits.

Further reading

Last updated:

© 2008–2026 XORBIN.COM. All rights reserved.