How to convert a .ppk key to OpenSSH, and back

Run puttygen key.ppk -O private-openssh -o id_ed25519. This writes an OpenSSH private key that ssh can use, and it keeps the same passphrase. To go the other way, run puttygen id_ed25519 -O private -o key.ppk. On Debian and Ubuntu the tool is in the putty-tools package.

Updated . All commands run with version 0.83 of the PPK tool on Debian 13, with ed25519 and RSA 3072 keys, with and without a passphrase.

Why you need to convert

OpenSSH cannot read the PPK format. Giving it a .ppk file directly fails. On our test system the message was this one, and other versions can show a different one, such as the one in invalid format:

Load key "key.ppk": error in libcrypto

The conversion changes only the file format. The key stays the same, so servers that already accept it keep accepting it.

Install the conversion tool

# Debian and Ubuntu
sudo apt install putty-tools

# macOS with Homebrew
brew install putty

From .ppk to OpenSSH

puttygen key.ppk -O private-openssh -o ~/.ssh/id_ed25519
puttygen key.ppk -O public-openssh -o ~/.ssh/id_ed25519.pub

If the key has a passphrase, puttygen asks for it. The new file keeps the same passphrase. Then check the result:

ssh-keygen -lf ~/.ssh/id_ed25519.pub
puttygen key.ppk -O fingerprint

Both print the same SHA256: fingerprint. The output file was created with mode 600 in our test, which is what ssh wants. If ssh complains anyway, see unprotected private key file.

To get only the public key line from an OpenSSH key, see how to get the public key from a private key.

RSA keys: old or new format

For an RSA key, private-openssh writes the old format, with BEGIN RSA PRIVATE KEY as the first line. For ed25519 it always writes the new one. If you want the newer format for RSA too, use:

puttygen key.ppk -O private-openssh-new -o ~/.ssh/id_rsa

Current OpenSSH reads both. Use the old one only for a tool that cannot read BEGIN OPENSSH PRIVATE KEY.

From OpenSSH to .ppk

puttygen ~/.ssh/id_ed25519 -O private -o key.ppk

Check the first line of the new file:

PuTTY-User-Key-File-3: ssh-ed25519

PPK version 3 and older tools

That 3 is the format version. It has been the default since 2021. It protects passphrases with Argon2, and tools from before 2021 that accept PPK files cannot read it. For those, write version 2:

puttygen ~/.ssh/id_ed25519 -O private -o key.ppk --ppk-param version=2

The first line then reads PuTTY-User-Key-File-2. Version 2 is less resistant to passphrase guessing, so use it only when you must, and upgrade the tool when you can.

Scripted use with a passphrase

These options read the passphrase from a file instead of asking. Put the file somewhere private and delete it afterwards:

puttygen key.ppk --old-passphrase pass.txt -O private-openssh -o id_ed25519

Add --new-passphrase newpass.txt to set a different one. To remove the passphrase, use an empty file, or /dev/null. Do that only if you really intend to leave the key unprotected.

With the key generator window on Windows

  1. Click Load and open the .ppk file, or use Conversions then Import for an OpenSSH key.
  2. To write OpenSSH, use Conversions then Export OpenSSH key.
  3. To write PPK, click Save private key.

Questions

Can OpenSSH use a .ppk file?

No. ssh does not read the PPK format. Convert the key first, as shown above, and use the new file.

Does converting a .ppk change the key?

No. Only the file format changes, so servers that accept the key keep accepting it. The fingerprint is the same before and after.

Can ssh-keygen convert a .ppk private key?

No. ssh-keygen does not read PPK private keys. Use the converter shown above.

Sources

More in Keys and login

All guides