Convert a base64 private key (pem) .pkey to a .ppk file for Putty
You can convert a base64/pem key, used by OpenSSL, or OpenSSH, to the Putty PPK format. The conversion requires OpenSSL, OpenSSH, and Putty.
Setp 1: Deciphering the key (if pertinent)
If your private key is encrypted, e.g. if you used Keybot, you will first need to decipher it:
openssl rsa -in encrypted_key.pkey -out decrypted_key.key
You will be prompted for the password. In case of error, a message will describe an password or decryption issue.
Setp 2: Securing the key file
To prevent security risks, apply appropriate permissions on the key file. Without that, ssh-keygen will refuse to work on the file.
chmod 600 decrypted_key.key
Step 3: Pre-converting the key without defining a password
You will need to pre-convert the key to be ready to be converted by Puttygen. When a password prompt appears, you will need to leave it empty, by pressing the enter key twice.
ssh-keygen -p -f decrypted_key.key
Step 4: Convert the key to PPK
You then need to convert the key to PPK:
If you use the unix cli binary:
puttygen decrypted_key.key -O private -o putty_key.ppk
You can also generate a public key for your SSH servers, using one of the two following commands, depending on your server:
puttygen decrypted_key.key -O public-openssh -o decrypted_key.pub
puttygen decrypted_key.key -O public -o decrypted_key.pub
If you use the Windows binary, you will need to use the graphical tool Puttygen:
- Open Puttygen, then go to the menu Conversions - Import key
- Select your private key file
- Your key has now been imported in Puttygen.
- In theActions section, click on Save private key.
- Choose the name and path to your new PPK file and save it.
- Then click on Save public key.
- Choose your public key file name and path, and save it.