RSA Key Pair Generator

Generate RSA key pairs in PEM, OpenSSH, and JWK formats with optional encryption.

RSA Key Pair Generator

Generate RSA public/private keys with optional OpenSSH, JWK, and fingerprints.

For broad compatibility use 2048. For higher security margin choose 3072 or 4096.


Use a strong passphrase. Store it separately from the private key.
Processing…
No output yet
Configure settings and click Generate.
Copied

About RSA Key Pair Generator

RSA Key Pair Generator – Online RSA key pair generator

Generate an RSA public and private key pair instantly for SSH, JWT signing, API encryption, or development testing. This RSA Key Pair Generator focuses on practical formats—PEM by default, with optional OpenSSH and JWK exports—so you can copy, verify, and download keys without extra conversions. Use it when you need reliable output for a lab, a CI fixture, a demo environment, or a quick compatibility check between systems.

How It Works

RSA is an asymmetric (public‑key) algorithm. Instead of one shared secret, you generate a pair: a public key that can be shared openly and a private key that must remain confidential. The strength of RSA comes from the difficulty of factoring a large composite number (the modulus) into its prime factors. In practice, modern libraries generate large random primes, build the modulus, compute a public exponent (often 65537), and derive the private exponent plus additional CRT parameters that speed up private operations.

When you click Generate, the tool requests a fresh RSA key pair using cryptographically secure randomness provided by the underlying platform. The public key is derived from the private key and then serialized into formats commonly required by real systems. Where possible, the tool also calculates a fingerprint so you can quickly confirm you uploaded or installed the intended key.

Although RSA is widely supported, it is not always the best algorithm for every new deployment. Many modern systems also support Ed25519 or ECDSA for SSH and signing because they provide smaller keys and faster operations. RSA remains popular due to its broad compatibility and long history, which is why a quick RSA generator is still useful for interoperability, legacy environments, and situations where an ecosystem specifically requires RSA.

Step-by-step flow

  • 1) Select a key size: Choose 2048, 3072, or 4096 bits depending on your performance needs and security policy. Larger sizes increase security margin but also increase CPU cost and file size.
  • 2) Generate the RSA key pair: The tool creates a new private key and immediately derives the corresponding public key from it.
  • 3) Export in the formats you need: You can copy PEM output directly into OpenSSL-based tooling, optionally generate an OpenSSH public key line for authorized_keys, and optionally export a JWK representation for web identity stacks.
  • 4) Protect and verify: If you provide a passphrase, the private key can be exported encrypted. A fingerprint can be displayed to help you verify the key during upload or distribution.
  • 5) Copy or download: Copy to clipboard for quick pasting or download a report file that contains the key material and metadata you selected.

Important security note: Treat generated private keys as secrets. Prefer generating production keys in a controlled environment, store them in a secrets manager or HSM when available, and follow rotation and access-control policies. For development and testing, disposable keys reduce risk—generate, use, and then discard them.

Key Features

Multiple key sizes with practical guidance

RSA key size is measured in bits of the modulus. A 2048-bit key is a common baseline for many services and is typically fast enough for day-to-day signing and key exchange operations. A 3072-bit key provides a higher margin and can be a good middle ground when policy demands a stronger setting but you still care about performance. A 4096-bit key can be useful for high-assurance scenarios or when you rotate keys infrequently, but it produces larger files and can make operations (especially signatures) slower. This tool keeps the choices focused on sizes most widely used in the real world.

Because compatibility matters, the generator aims to produce keys that are easy to import into common environments, including OpenSSL workflows, server configuration files, and web stacks that accept standard PEM blocks.

PEM output for broad compatibility

PEM is the “lingua franca” of key material for many tools and libraries. A PEM key is base64 data wrapped in header and footer lines such as BEGIN PUBLIC KEY or BEGIN RSA PRIVATE KEY. PEM works well with OpenSSL commands, many language crypto libraries, cloud consoles, and appliances. The tool outputs a clean PEM public key and a corresponding PEM private key, keeping the content copy-ready for config files and environment variables (where appropriate).

When pasting PEM into configuration, be mindful of line breaks. Some systems accept a multi-line PEM file only, while others accept a single-line value where newlines are encoded as \n. If you see import errors, verify you preserved the header, footer, and the exact base64 body without extra spaces.

OpenSSH public key export with optional comment

SSH typically stores public keys as a single line like ssh-rsa AAAA… comment. If you enable OpenSSH export, the tool converts the RSA public key parameters into the standard OpenSSH wire format and then base64-encodes that blob. You can add a short comment such as a username, laptop name, or purpose label. Comments help when you have multiple keys registered across servers, Git platforms, CI services, or bastion hosts.

OpenSSH has been gradually discouraging some older RSA signature modes in favor of stronger defaults, but RSA keys themselves are still accepted by many systems—especially when using modern SHA-2 signature algorithms. If you’re using SSH for new deployments and you have a choice, consider Ed25519 for a smaller key and fast operations. If you must use RSA, pick an appropriate size and ensure your SSH server/client supports modern RSA signatures.

JWK export for OAuth/OIDC and JWT ecosystems

Web identity systems commonly publish a JWKS (JSON Web Key Set) endpoint that contains one or more JWK entries. When enabled, the tool outputs a JWK representation containing the RSA modulus (n) and exponent (e) encoded using base64url. This makes it easier to integrate with JWT verification middleware, API gateways, identity providers, and custom authorization servers.

A typical workflow is to keep the private key in a secure service and publish only the public part via JWKS so other services can verify signatures. You can use this generator to create test keys for a staging JWKS endpoint, validate your JWT pipeline, and confirm that consumers correctly parse and cache rotated keys.

Fingerprints and verification helpers

Key fingerprints provide a compact identifier for a public key. Many SSH tools show SHA-256 fingerprints, and cloud consoles often display fingerprints when you upload a public key. This tool can compute a SHA-256 fingerprint derived from the OpenSSH public key blob (when OpenSSH export is enabled), which makes it easier to compare what you generated with what a service reports after upload.

Fingerprints are not a security boundary by themselves, but they are excellent for catching common mistakes: copying the wrong key, trimming whitespace, uploading an older key by accident, or mixing up environments. When you distribute a public key to a teammate, sharing the fingerprint alongside the key is a simple verification step.

Use Cases

  • SSH access provisioning: Generate an OpenSSH public key to add to ~/.ssh/authorized_keys on a server, or upload it to a provider’s “SSH keys” section for instance access.
  • Git hosting and CI integrations: Create a deploy key for repositories, or a key pair for CI jobs that need controlled access to build artifacts or infrastructure.
  • JWT signing and verification labs: Generate a pair to test RS256/RS512 signing flows, then publish the public key via a JWKS document to confirm downstream services verify tokens correctly.
  • API encryption prototypes: Use the public key to encrypt a symmetric key or short secret, then decrypt it with the private key as part of a proof-of-concept or integration test.
  • Interoperability checks: Compare how different systems import PEM keys, whether they accept encrypted private keys, and which RSA sizes they support.
  • Education and documentation: Produce example keys for tutorials, internal docs, and onboarding guides without reusing production secrets.
  • Short-lived fixtures: Generate disposable keys to test your code paths for key parsing, certificate requests, signature verification, and failure handling.

RSA key generation is also useful for troubleshooting: if a service rejects your key, generate a new one with a different size or format and see whether the import succeeds. This helps isolate whether the problem is a formatting issue, a policy restriction, or a compatibility limitation in the target environment.

Optimization Tips

Match key size to performance and policy

If you are generating keys for a high-traffic signing service, performance matters. RSA operations are computationally heavier than modern elliptic-curve alternatives, and larger RSA keys increase cost further. For many applications, 2048 bits is a pragmatic baseline. If your security policy requires stronger settings, consider 3072 bits as a balanced option. Reserve 4096 bits for cases where compatibility is required and the performance impact is acceptable.

Also consider what you are using RSA for. RSA is often used for signatures and key wrapping rather than bulk encryption. If your design requires encrypting large blobs, use hybrid encryption: generate a random symmetric key (AES), encrypt the data symmetrically, and encrypt only the symmetric key with RSA.

Use passphrase encryption for portable private keys

If you will store the private key as a file on disk, enabling passphrase encryption reduces risk from accidental copies and backups. Use a long, unique passphrase and store it separately from the private key. For automation, avoid embedding private keys directly in source repositories. Prefer a secrets manager, short-lived credentials, or a managed signing service. For SSH, consider using an SSH agent so you can keep the key encrypted at rest while still making it usable in sessions.

Remember that passphrase encryption is only as strong as the passphrase and your operational practices. If the passphrase is weak or stored alongside the key, the protective value drops significantly.

Verify fingerprints and plan for rotation

Before trusting a key in production, verify it. Compare the SHA-256 fingerprint displayed here with what your target system shows after upload, and keep a small inventory of fingerprints per environment. When a key is retired, remove it from authorized key lists, JWKS documents, and service dashboards. If your system supports rotation, set an expiry process so keys do not live indefinitely.

For JWT signing, a common strategy is to publish multiple public keys in JWKS during rotation: add a new key, start signing with it, keep the old key available for verification until all old tokens expire, then remove the old key.

An RSA key pair includes a public key and a private key that are mathematically linked. The public key is shared to enable encryption to you or verification of your signatures. The private key is kept secret and is used to decrypt data encrypted for you or to create signatures that others verify with the public key. RSA security relies on the practical difficulty of factoring the large modulus into its prime components.

Choose 2048 bits for broad compatibility and good performance. Use 3072 bits when you want a stronger margin while keeping performance reasonable. Use 4096 bits when policy demands it or when you can tolerate larger keys and slower operations. If you are deploying new infrastructure and you have flexibility, consider whether an elliptic-curve key type is acceptable and supported, especially for SSH.

PEM is a base64-encoded representation wrapped in headers and footers and is commonly used by OpenSSL and many libraries. OpenSSH public keys are one-line strings used for SSH authorization and key uploads. JWK is a JSON representation used in OAuth/OIDC and JWT ecosystems, where the public key may be published as part of a JWKS endpoint for token verification.

Yes. If you enable private-key encryption and provide a passphrase, the tool exports the private key in encrypted form using a common cipher. This helps protect the key at rest, especially when stored on disk. Use a strong passphrase, store it separately, and prefer a secrets manager for operational environments.

RSA is usually not used to encrypt large files directly. It is commonly used to encrypt small values, such as symmetric keys, or to sign data. For large files and messages, use hybrid encryption: encrypt the data with a symmetric algorithm like AES and encrypt only the symmetric key with RSA.

Why Choose This Tool

This RSA Key Pair Generator emphasizes realistic defaults, clear outputs, and formats that map directly to common tasks: PEM for OpenSSL tooling, OpenSSH for server access, and JWK for web identity. The interface is designed to make verification simple—fingerprints, comments, and an easy download option help you move from generation to deployment with fewer mistakes.

Whether you are spinning up a test environment, validating a JWKS pipeline, or creating short-lived access keys for a controlled scenario, the generator provides a straightforward workflow. For production use, follow best practices: generate keys in a trusted environment, store private keys securely, minimize access, and rotate keys on a schedule aligned with your risk and compliance needs.