LinuxCommandLibrary

openssl-rsa

TLDR

View RSA key details

$ openssl rsa -in [private.key] -text -noout
copy
Extract public key
$ openssl rsa -in [private.key] -pubout -out [public.key]
copy
Remove passphrase
$ openssl rsa -in [encrypted.key] -out [decrypted.key]
copy
Add passphrase
$ openssl rsa -in [private.key] -aes256 -out [encrypted.key]
copy
Convert PEM to DER
$ openssl rsa -in [private.key] -outform DER -out [private.der]
copy
Check key validity
$ openssl rsa -in [private.key] -check
copy

SYNOPSIS

openssl rsa [options] [-in file] [-out file]

DESCRIPTION

openssl rsa processes RSA keys. It can convert formats, extract public keys, add/remove encryption, and verify key integrity.
For general key operations, consider using openssl pkey instead.

PARAMETERS

-in file

Input file.
-out file
Output file.
-pubout
Output public key.
-pubin
Input is public key.
-text
Print components.
-noout
Don't output key.
-check
Check consistency.
-aes256, -aes128
Encrypt output.
-inform, -outform
Input/output format.

KEY COMPONENTS

$ n - Modulus
e - Public exponent
d - Private exponent
p, q - Prime factors
copy

CAVEATS

RSA-specific; use pkey for other algorithms. Protect private keys. Consider Ed25519 for new applications.

HISTORY

RSA key handling has been core OpenSSL functionality since the library's creation, though genpkey/pkey are now preferred.

SEE ALSO

Copied to clipboard