Converting a putty ppk file to a pem file for accessing AWS ec2 instances

A few weeks ago I was working on a project in which the existing developers had setup access to their AWS EC2 instances using putty as their ssh client due to them running on Windows 7. They provided the putty private key file they setup but that didn’t do me any good because I was running OS X. Here is a list of steps I took to convert that PPK file to a PEM file that I could use to SSH into any EC2 instance.

  • To start you will need either macports or homebrew.
  • if using macports you will run the following command to install putty for mac:
  • if you are using homebrew you will run the following command to install putty:
  • The remaining commands will be the same when using macports or homebrew. To generate the pem file run the following command:
    Keep in mind that you will want to substitute the name of your ppk file in place of the privatekey.ppk name I used. You will also want to change the name of the pem file you want to create rather than using privatekey.pem, unless of course you want to use privatekey.pem.
  • Next you should place the privatekey.pem file in your ~/.ssh directory
  • Now, lets set the pem file to have the proper permissions:

That’s it. You now have a valid pem file that you can use to connect to your EC2 instances from your Mac. Below is an example of the command you can now run to connect to your instances:

That’s it for this post, hope this helps someone out in the future. And by someone I most likely mean future me!

Posted in AWS Tagged with: , , , ,
3 comments on “Converting a putty ppk file to a pem file for accessing AWS ec2 instances
  1. On windows, the stated puttygen command just starts the puttygen GUI.
    You can still generate a pem file from there, just go to Menu -> Conversions -> Export OpenSSH key.

  2. Volodymyr says:

    Works fine. Thanks!

  3. jean-pierre says:

    Thanks. This was very helpful.

Leave a Reply