Linux "pkey" Command Line Options and Examples
public or private key processing tool

The pkey command processes public or private keys. They can be converted between various forms and their components printed out..


Usage:

openssl pkey [-help] [-inform PEM|DER] [-outform PEM|DER] [-in filename] [-passin arg] [-out filename]
[-passout arg] [-traditional] [-cipher] [-text] [-text_pub] [-noout] [-pubin] [-pubout] [-engine id]






Command Line Options:

-help
Print out a usage message.
pkey -help ...
-inform
This specifies the input format DER or PEM.
pkey -inform ...
-outform
This specifies the output format, the options have the same meaning as the -inform option.
pkey -outform ...
-in
This specifies the input filename to read a key from or standard input if this option is not specified. Ifthe key is encrypted a pass phrase will be prompted for.
pkey -in ...
-passin
the input file password source. For more information about the format of arg see the PASS PHRASE ARGUMENTSsection in openssl(1).
pkey -passin ...
-out
This specifies the output filename to write a key to or standard output if this option is not specified.If any encryption options are set then a pass phrase will be prompted for. The output filename should notbe the same as the input filename.
pkey -out ...
-passout
the output file password source. For more information about the format of arg see the PASS PHRASEARGUMENTS section in openssl(1).
pkey -passout ...
-traditional
normally a private key is written using standard format: this is PKCS#8 form with the appropriateencryption algorithm (if any). If the -traditional option is specified then the older "traditional" formatis used instead.
pkey -traditional ...
-cipher
These options encrypt the private key with the supplied cipher. Any algorithm name accepted byEVP_get_cipherbyname() is acceptable such as des3.
pkey -cipher ...
-text
prints out the various public or private key components in plain text in addition to the encoded version.
pkey -text ...
-text_pub
print out only public key components even if a private key is being processed.
pkey -text_pub ...
-noout
do not output the encoded version of the key.
pkey -noout ...
-pubin
by default a private key is read from the input file: with this option a public key is read instead.
pkey -pubin ...
-pubout
by default a private key is output: with this option a public key will be output instead. This option isautomatically set if the input is a public key.
pkey -pubout ...
-engine
specifying an engine (by its unique id string) will cause pkey to attempt to obtain a functional referenceto the specified engine, thus initialising it if needed. The engine will then be set as the default forall available algorithms.EXAMPLESTo remove the pass phrase on an RSA private key:openssl pkey -in key.pem -out keyout.pemTo encrypt a private key using triple DES:openssl pkey -in key.pem -des3 -out keyout.pemTo convert a private key from PEM to DER format:openssl pkey -in key.pem -outform DER -out keyout.derTo print out the components of a private key to standard output:openssl pkey -in key.pem -text -nooutTo print out the public components of a private key to standard output:openssl pkey -in key.pem -text_pub -nooutTo just output the public part of a private key:openssl pkey -in key.pem -pubout -out pubkey.pem
pkey -engine ...