Convert a PuTTY .ppk key to OpenSSH format, and PPK version 3
How to export a PuTTY .ppk key as an OpenSSH key with PuTTYgen, which export option gives the newer format, and what PPK version 3 means for older tools.
A .ppk file is PuTTY's own private key format. Other SSH clients usually want an OpenSSH key. PuTTYgen can convert between them.
Why a conversion is needed
The PuTTY manual explains that SSH-2 private keys have no standard format. OpenSSH, ssh.com and PuTTY each use their own, so a key made with one client cannot be used in another until it is converted.
Convert a .ppk to OpenSSH with PuTTYgen
- Open PuTTYgen and click Load. Pick the
.ppkfile. Type its passphrase if it asks. - Open the Conversions menu and pick an Export OpenSSH key option (see below).
- Save the file. PuTTYgen warns you if you are about to save a key without a passphrase.
The manual says exporting works like saving: you must type the passphrase beforehand.
Which export option
PuTTYgen offers two options for OpenSSH:
- Export OpenSSH key picks the oldest format that supports the key type, for the widest compatibility with older OpenSSH versions. For newer key types such as Ed25519 it uses the newer format, because that is the only legal one.
- Export OpenSSH key (force new file format) uses OpenSSH's newer "native" format even for RSA, DSA or ECDSA keys. The manual says this format has better resistance to passphrase guessing and keeps comments. Use it when the key is only used by OpenSSH 6.5 (2014) or newer.
So for an RSA key the two options give different files.
The newer format starts with -----BEGIN OPENSSH PRIVATE KEY-----. The older RSA format starts with -----BEGIN RSA PRIVATE KEY-----. Many SSH clients import only the newer OpenSSH format. For an RSA key from PuTTYgen, use Export OpenSSH key (force new file format) so the file starts with that header. See Key types and formats.
PPK version 3 and older tools
PuTTYgen saves PPK files as version 3 by default. The PuTTY manual says you may need version 2 if the file has to load in PuTTY 0.74 and older, or in other tools that do not support version 3 yet. Version 3 was introduced in 2021. Version 2 is less resistant to brute-force decryption of the passphrase.
If an older program rejects your .ppk file as too new, save a copy as version 2 in PuTTYgen under Key, then Parameters for saving key files, and set PPK file version to 2. Or update the program.
The public key for the host
PuTTYgen shows the public key in the box labelled for pasting into an OpenSSH authorized_keys file. Add that line to ~/.ssh/authorized_keys on the host. The manual gives that file as the place for OpenSSH servers. See Authorized keys and permissions.
Related
- Key types and formats
- Authorized keys and permissions
- SSH keys
- PuTTY "No supported authentication methods available (server sent: publickey)"
- PuTTY "Server refused our key": why and how to fix it