openssl is not recognized, see Add to PATH.Generate a 2048-bit RSA key
Open Command Prompt or PowerShell in your working directory and run:
This creates private.key in the current directory — an unencrypted RSA private key in PEM format.
2048-bit vs 4096-bit
2048-bit
Widely accepted for most use cases. Fast to generate and use. Recommended minimum for new keys. NIST-approved through at least 2030.
4096-bit stronger
Larger key = stronger security but slower operations. Use for long-lived certificates (10+ years) or high-security CAs. Takes longer to generate.
Generate a key with a passphrase
Add -aes256 to encrypt the key with AES-256. You will be prompted for a passphrase:
The encrypted key requires the passphrase every time it is used. To remove the passphrase later:
Inspect the generated key
What to do with your key
Key generation questions
Where is the key file saved?
cd to navigate to your target folder first, or specify a full path: openssl genrsa -out C:\certs\private.key 2048.Should I use RSA or ECDSA in 2025?
openssl ecparam -genkey -name prime256v1 -out ec.key. RSA remains widely compatible with legacy systems.Is the key format PEM or DER?
openssl genrsa outputs PEM format by default (base64-encoded with -----BEGIN RSA PRIVATE KEY----- headers). To generate DER format: add -outform DER to the command.Can I generate a key non-interactively (no prompts)?
-aes256 (or any -cipher flag) and the command runs without any prompts. The output key will be unencrypted. Useful for scripts and automation.Need to generate a CSR next?
Use the key you just created to create a Certificate Signing Request.
Related guides