Triggered today by Remote Desktop Manager, whose SSH Key Generator offered to save a private key in OpenSSH format, but then proceeded to store it in PKCS#1 / OpenSSL format, while using the same random *.pri file extension for two of the offered formats.

save as

I just wanted to connect to an AWS EC2 instance, but WinSCP, FileZilla and PuTTY all use different private key formats.

Feel free to offer more insight, this is just my current incomplete understanding.

1 Answer 1


The file extension is often either random or not enough to identify the format.

Broad categories:

  • PEM files with ASN.1 data, encoded with DER
  • PEM files with data encoded in some other format
  • Non-PEM formats

PEM files wrap Base64 between -----BEGIN----- and -----END----- "tags". They are also commonly used to contain both private key and SSL certificate (-chain). Use an online ASN.1 decoder to check the Base64 contents of a PEM file.

PEM Files

PKCS#1 / OpenSSL: id_rsa, *.pem, *.der, *.key, ...


PuTTY Key Generator calls this "OpenSSH SSH-2 private key (old PEM format)" (?). The "SSLeay" or "traditional" format, according to this answer. Base64 starts with MII.... ASN.1 content. More info.

PKCS#8: *.pem, *.der, *.key, ...


Base64 of the unencrypted variation starts with MII...IBADAN. ASN.1 content, basically PKCS#1 plus version info. More info.

OpenSSH: *.??? (don't know what a typical file extension would be)


PEM on the outside, but non-ASN.1 content. Apparently a somewhat undocumented format.

Non-PEM Files

PuTTY Private Key: *.ppk

Content also contains human readable words identifying it as a putty private key.

PKCS#12 / PFX: *.p12, *.pfx

PFX is a Microsoft format, later released in cleaned-up form as PKCS#12. The content is binary, and can contain not only a private key, but also an SSL certificate (-chain).

  • The OpenSSH format doesn't use DER, but it does use standard SSHv2 packet data types (e.g. 32-bit length, <...> is exactly the standard format of a 'string' type in SSHv2 packets). So the documentation at PROTOCOL.key and draft-miller-ssh-agent should be sufficient, combined with data type definitions at RFC 4251. Commented Jan 7, 2020 at 8:24
  • For OpenSSH 'new' format github.com/openssh/openssh-portable/blob/master/PROTOCOL.key . Nit: PKCS12 can (and almost always does) contain X.509v3/PKIX certs, which are used not only for SSL/TLS but also S/MIME, XMLdsig/enc, some code signing, PDF signing, and more. (But not SSH.) Commented Jan 7, 2020 at 8:26
  • 2
    Please do NOT use an online decoder for your private PEM files. They are PRIVATE.
    – Rich Remer
    Commented Aug 19, 2022 at 15:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .