Tech: Convert .ppk file to .pem for ssh to EC2

On Linux

Install the putty tools, if you don’t have on Linux:

sudo apt-get install putty-tools

Generate the pem file run the following command:

puttygen ppkkey.ppk -O private-openssh -o pemkey.pem

Place the pemkey.pem file in your ~/.ssh directory:

cp pemkey.pem ~/.ssh

Set the pem file to have the proper permissions:

chmod 400 pemkey.pem

Now, we have a valid pem file that we can use to connect to our EC2 instances from Linux. Below is an example:

ssh -i pemkey.pem user@ec2-instancedotcom

Similarly, if we want to convert pem file to ppk , we can do it like this:

puttygen pemKey.pem -o ppkKey.ppk -O private

Flags:

-o Tells it where to write out the converted putty private key
-O private Tells it that you want a putty private key.


On MAC

Install putty

brew install putty

Convert ppk to pem

puttygen privatekey.ppk -O private-openssh -o privatekey.pem

Set permission

chmod go-rw privatekey.pem

Connect

ssh -i privatekey.pem [email protected]

Leave a Reply

Your email address will not be published.Required fields are marked *