Amazon EC2 allows you to create Keypair and download the private key(.pem) to your local system. PuTTY is the SSH client tool to connect to the Linux instances and PuTTY does not natively support the private key format for SSH keys.
If you are using PuTTY to connect to the EC2 instance, then you should use only .ppk format private key.
PuTTY provides a tool named PuTTYgen, which converts keys to the required format for PuTTY. PuTTYgen used to convert private key (.pem file) into (.ppk file) and vice versa.
Windows
Pre-Requisite:
- Download and install the PuTTYgen
Convert a .ppk file to a .pem file
Start PuTTYgen tool, click on Load and navigate to your .ppk format file.
Choose the .ppk file, and then choose Open.
3. From the menu at the top of the PuTTY Key Generator, choose Conversions, Export OpenSSH Key.
4. If you didn’t enter a passphrase, you receive a PuTTYgen warning. Choose Yes.
5. Name the file and add the .pem extension.
6. Choose Save.
Convert a .pem file to a .ppk file
Start PuTTYgen tool, click on Load and navigate to your .pem format file.
Note that by default, PuTTYgen displays only files with the extension .ppk. To locate your .pem file, choose the option to display files of all types.
3. Choose the .pem file, and then choose Open.
4. PuTTYgen displays a notice that the .pem
file was successfully imported. Choose OK.
5. Click Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes.
6. Click Save. PuTTY automatically adds the .ppk
file extension.
Linux
Pre-Requisite:
- Download and install the PuTTY using below commands
rpm based – # yum install putty -y
dpkg based – #apt-get install putty-tools
verify PuTTYgen version
#puttygen –version puttygen: Release 0.76 Build platform: 64-bit Unix Compiler: gcc 4.8.5 20150623 (Red Hat 4.8.5-44) Source commit: 1fd7baa7344bb38d62a024e5dba3a720c67d05cf
Convert a .ppk file to a .pem file
- Run below command to verify the .ppk key location
#ls -l -rw——- 1 root root 1462 Sep 14 13:43 devops.ppk
2. Run below command to convert the key from .ppk to .pem
#puttygen devops.ppk -O private-openssh -o devops.pem
3. Verify that the key is converted and .ppk is now available
#ls -l -rw——- 1 root root 1675 Sep 14 13:44 devops.pem -rw——- 1 root root 1462 Sep 14 13:43 devops.ppk
Convert a .pem file to a .ppk file
- Run below command to confirm the .pem key file location
#ls -l devops.pem -rw-r–r– 1 root root 1676 Sep 14 13:42 devops.pem
2. Run below command to convert the key from .pem to .ppk
#puttygen devops.pem -o devops.ppk -O private
3. Verify that the key converted and .ppk now available.
#ls -l -rw——- 1 root root 1675 Sep 14 13:44 devops.pem -rw——- 1 root root 1462 Sep 14 13:43 devops.ppk