I want to convert my Amazon Elastic Compute Cloud (Amazon EC2) Privacy Enhanced Mail (.pem) file to a PuTTY Private Key (.ppk) file. Or, I want to convert a .ppk file to a .pem file.
Short description
PuTTY doesn't natively support the private key format (.pem) that Amazon EC2 generates. Before you can use PuTTY to connect to your instance, you must convert your private key into a .ppk file. Use the PuTTYgen tool for this conversion.
Resolution
Windows - install PuTTYgen
Most Windows operating systems have PuTTY installed. If your system doesn't, then download and install PuTTYgen. For more information on PuTTYgen, see PuTTYgen on the SSH website.
Windows - convert a .pem file to a .ppk file
Start PuTTYgen, and then convert the .pem file to a .ppk file. For detailed steps, see Convert your private key using PuTTYgen.
Windows - convert a .ppk file to a .pem file
- Start PuTTYgen. For Actions, choose Load, and then navigate to your .ppk file.
- Choose the .ppk file, and then choose Open.
- (Optional) For Key passphrase, enter a passphrase. For Confirm passphrase, re-enter your passphrase.
Note: Although a passphrase isn't required, it's a best practice to specify one. This is a security measure to protect the private key from unauthorized use. A passphrase makes automation difficult, because users must manually log in to an instance or copy files to an instance.
- From the menu at the top of the PuTTY Key Generator, choose Conversions, Export OpenSSH Key.
Note: If you didn't enter a passphrase, then you receive a PuTTYgen warning. Choose Yes.
- Name the file and add the .pem extension.
- Choose Save.
Unix or Linux - install PuTTY
Install PuTTY, if it's not already on your system.
The Extra Packages for Enterprise Linux (EPEL) repository contains the PuTTY package. You must activate the EPEL repository before you install PuTTY.
Note: Amazon Linux 2023 (AL2023) doesn't support EPEL. For more information, see Extra Packages for Enterprise Linux (EPEL).
To install PuTTY, run one of the following commands:
RPM-based
$ yum install putty
Dpkg-based
$ apt-get install putty-tools
Unix or Linux - .pem and .ppk files
The .ppk file is supported only on Windows PuTTYGen. It must be converted to a .pem file to be used on Linux. Run the puttygen command to convert a .ppk file in to a .pem file:
$ puttygen ppkkey.ppk -O private-openssh -o pemkey.pem
Similarly, you can use the puttygen to convert a .pem file to a .ppk file:
$ puttygen pemKey.pem -o ppkKey.ppk -O private
Related information
Amazon EC2 key pairs and Amazon EC2 instances