.TH "SSHPK\-CONV" "" "January 2020" "" ""
.SH "NAME"
sshpk\-conv \- convert between key formats
.SH SYNOPSYS
.P
\fBsshpk\-conv\fP \-t FORMAT [FILENAME] [OPTIONS\.\.\.]
.P
\fBsshpk\-conv\fP \-i [FILENAME] [OPTIONS\.\.\.]
.SH DESCRIPTION
.P
Reads in a public or private key and converts it between different formats,
particularly formats used in the SSH protocol and the well\-known PEM PKCS#1/7
formats\.
.P
In the second form, with the \fB\-i\fP option given, identifies a key and prints to 
stderr information about its nature, size and fingerprint\.
.SH EXAMPLES
.P
Assume the following SSH\-format public key in \fBid_ecdsa\.pub\fP:
.P
.RS 2
.nf
ecdsa\-sha2\-nistp256 AAAAE2VjZHNhLXNoYTI\.\.\.9M/4c4= user@host
.fi
.RE
.P
Identify it with \fB\-i\fP:
.P
.RS 2
.nf
$ sshpk\-conv \-i id_ecdsa\.pub
id_ecdsa: a 256 bit ECDSA public key
ECDSA curve: nistp256
Comment: user@host
Fingerprint:
  SHA256:vCNX7eUkdvqqW0m4PoxQAZRv+CM4P4fS8+CbliAvS4k
  81:ad:d5:57:e5:6f:7d:a2:93:79:56:af:d7:c0:38:51
.fi
.RE
.P
Convert it to \fBpkcs8\fP format, for use with e\.g\. OpenSSL:
.P
.RS 2
.nf
$ sshpk\-conv \-t pkcs8 id_ecdsa
\-\-\-\-\-BEGIN PUBLIC KEY\-\-\-\-\-
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAsA4R6N6AS3gzaPBeLjG2ObSgUsR
zOt+kWJoijLnw3ZMYUKmAx+lD0I5XUxdrPcs1vH5f3cn9TvRvO9L0z/hzg==
\-\-\-\-\-END PUBLIC KEY\-\-\-\-\-
.fi
.RE
.P
Retrieve the public half of a private key:
.P
.RS 2
.nf
$ openssl genrsa 2048 | sshpk\-conv \-t ssh \-c foo@bar
ssh\-rsa AAAAB3NzaC1yc2EAAA\.\.\.koK7 foo@bar
.fi
.RE
.P
Convert a private key to PKCS#1 (OpenSSL) format from a new\-style OpenSSH key
format (the \fBssh\-keygen \-o\fP format):
.P
.RS 2
.nf
$ ssh\-keygen \-o \-f foobar
\|\.\.\.
$ sshpk\-conv \-p \-t pkcs1 foobar
\-\-\-\-\-BEGIN RSA PRIVATE KEY\-\-\-\-\-
MIIDpAIBAAKCAQEA6T/GYJndb1TRH3+NL\.\.\.\.
\-\-\-\-\-END RSA PRIVATE KEY\-\-\-\-\-
.fi
.RE
.SH OPTIONS
.P
\fB\-i, \-\-identify\fP
  Instead of converting the key, output identifying information about it to 
  stderr, including its type, size and fingerprints\.
.P
\fB\-p, \-\-private\fP
  Treat the key as a private key instead of a public key (the default)\. If you
  supply \fBsshpk\-conv\fP with a private key and do not give this option, it will
  extract only the public half of the key from it and work with that\.
.P
\fB\-f PATH, \-\-file=PATH\fP
  Input file to take the key from instead of stdin\. If a filename is supplied
  as a positional argument, it is equivalent to using this option\.
.P
\fB\-o PATH, \-\-out=PATH\fP
  Output file name to use instead of stdout\.
.P
\fB\-T FORMAT, \-\-informat=FORMAT\fP
.P
\fB\-t FORMAT, \-\-outformat=FORMAT\fP
  Selects the input and output formats to be used (see FORMATS, below)\.
.P
\fB\-c TEXT, \-\-comment=TEXT\fP
  Sets the key comment for the output file, if supported\.
.SH FORMATS
.P
Currently supported formats:
.P
\fBpem, pkcs1\fP
  The standard PEM format used by older OpenSSH and most TLS libraries such as
  OpenSSL\. The classic \fBid_rsa\fP file is usually in this format\. It is an ASN\.1
  encoded structure, base64\-encoded and placed between PEM headers\.
.P
\fBssh\fP
  The SSH public key text format (the format of an \fBid_rsa\.pub\fP file)\. A single
  line, containing 3 space separated parts: the key type, key body and optional
  key comment\.
.P
\fBpkcs8\fP
  A newer PEM format, usually used only for public keys by TLS libraries such
  as OpenSSL\. The ASN\.1 structure is more generic than that of \fBpkcs1\fP\|\.
.P
\fBopenssh\fP
  The new \fBssh\-keygen \-o\fP format from OpenSSH\. This can be mistaken for a PEM
  encoding but is actually an OpenSSH internal format\.
.P
\fBrfc4253\fP
  The internal binary format of keys when sent over the wire in the SSH
  protocol\. This is also the format that the \fBssh\-agent\fP uses in its protocol\.
.SH SEE ALSO
.P
ssh\-keygen(1), openssl(1)
.SH BUGS
.P
Encrypted (password\-protected) keys are not supported\.
.P
Report bugs at Github \fIhttps://github\.com/arekinath/node\-sshpk/issues\fR

