openssl genpkey

The OpenSSL subcommand that generates a new private key, such as an Ed25519 or RSA key, and writes it to a file.

In more detail

You choose the algorithm with -algorithm and the output file with -out, and options such as -pkeyopt set details like key size. The file it writes holds the private key, and the public key can be derived from it later with openssl pkey. Protect the output like any secret, or add a cipher option such as -aes256 to encrypt it with a passphrase.

Example

openssl genpkey -algorithm ed25519 -out alice.key

Related terms

Taught in

References