openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out key.pem

Category: Security & Hardening

openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:4096 -out key.pem

Generate a 4096-bit RSA private key

Creates a new RSA private key of 4096 bits with the modern genpkey interface, the recommended replacement for the old genrsa command. Guard key.pem carefully; anyone holding it can impersonate your service. Inspect the key with openssl pkey -in key.pem -text -noout.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.