How to generate an RSA keypair
The openssl
tool provides two subcommands for generating RSA keypairs – genrsa
and genpkey
. The former can generate only an RSA keypair, while the latter is a more generic subcommand that can generate any type of keypair supported by OpenSSL. genrsa
is declared deprecated since OpenSSL 3.0, thus we will use genpkey
.
Documentation for the openssl genpkey
subcommand can be found on the openssl-genpkey
man page:
man openssl-genpkey
Why such a name, genpkey
? OpenSSL has a concept of a Public or Private Key (PKEY). Here, it is important to clear up one confusion. Throughout the OpenSSL documentation, you will find mentions about public and private keys. Very often when mentioning a private key, the documentation really means a keypair. It applies to both command-line tools documentation and OpenSSL API documentation. For example, the description
part of the openssl-genpkey
man page says, The genpkey command generates a private key. If only...