Converting SSH2 RSA Private Key to .pem using openssl Converting SSH2 RSA Private Key to .pem using openssl unix unix

Converting SSH2 RSA Private Key to .pem using openssl


I just answered your question on Unix&Linux.
Since your question here is still standing, however, I won't let it go unanswered.

ssh-keygen -p can convert between SSH2 and PEM formats:

 -m key_format         Specify a key format for key generation, the -i (import),         -e (export) conversion options, and the -p change         passphrase operation. The latter may be used to convert         between OpenSSH private key and PEM private key formats.         The supported key formats are: “RFC4716” (RFC 4716/SSH2         public or private key), “PKCS8” (PKCS8 public or private         key) or “PEM” (PEM public key). By default OpenSSH will         write newly-generated private keys in its own format, but         when converting public keys for export the default format         is “RFC4716”. Setting a format of “PEM” when generating or         updating a supported private key type will cause the key to         be stored in the legacy PEM private key format.

From SSH2 to PEM:

ssh-keygen -p -f id_rsa -m PEM

From PEM to SSH2:

ssh-keygen -p -f id_rsa -m SSH2

Warning: The specified file gets overwritten and updated in-place!

Note: While ssh-keygen-g3 is linked to a commercial product, ssh-keygen is the more common, open-source counterpart. You can get it for free on your system, and it is available for Linux, Windows, FreeBSD and PASE among others. If you prefer, you can perform the conversion on a system that has it: SSH2/PEM keys are just plain text files after all, just be careful not to leave them around.