51

I have generated and downloaded a private .pem key from AWS. However, to use Putty in order to connect to the virtual machine, I must have that key in .ppk format. The process of conversion is detailed in roughly 20 lines here:

I am using Linux Mint (an Ubuntu distro) and I know I can use puttygen in the terminal. However, I have no idea how to use this tool, nor how to configure the needed parameters. When I type puttygen --help I get

PuTTYgen unidentified build, Aug  7 2013 12:24:58
Usage: puttygen ( keyfile | -t type [ -b bits ] )
                [ -C comment ] [ -P ] [ -q ]
                [ -o output-keyfile ] [ -O type | -l | -L | -p ]
  -t    specify key type when generating (rsa, dsa, rsa1)
  -b    specify number of bits when generating key
  -C    change or specify key comment
  -P    change key passphrase
  -q    quiet: do not display progress bar
  -O    specify output type:
           private             output PuTTY private key format
           private-openssh     export OpenSSH private key
           private-sshcom      export ssh.com private key
           public              standard / ssh.com public key
           public-openssh      OpenSSH public key
           fingerprint         output the key fingerprint
  -o    specify output file
  -l    equivalent to `-O fingerprint'
  -L    equivalent to `-O public-openssh'
  -p    equivalent to `-O public'

But I have no idea whatsoever on how to do what the website tells me to do and all my tentatives failed so far.

How do I do what the website tells me to do, using puttygen on the terminal?

1

3 Answers 3

72

Using the GUI

See this SO Q&A on how to do exactly what you want, titled: Convert PEM to PPK file format.

excerpt

  1. Download your .pem from AWS
  2. Open PuTTYgen, select Type of key to generate as: SSH-2 RSA
  3. Click "Load" on the right side about 3/4 down
  4. Set the file type to *.*
  5. Browse to, and Open your .pem file
  6. PuTTY will auto-detect everything it needs, and you just need to click "Save private key" and you can save your ppk key for use with PuTTY

Using the command line

If on the other hand you'd like to convert a .pem to .ppk file via the command line tool puttygen, I did come across this solution on SO in this Q&A titled:

excerpt

$ puttygen keyfile.pem -O private -o avdev.ppk

For the public key:

$ puttygen keyfile.pem -L

References

5
  • steps 2 to 6 also work for other private key file types (e.g. resulting file from a Git Bash ssh-keygen command), thanks!
    – AtAFork
    Sep 23, 2016 at 0:06
  • doesn't work anymore from the command line Mar 29, 2017 at 16:00
  • Any thoughts on how this would work on OSX, PuTTYgen isn't available
    – Qasim
    Jun 21, 2017 at 10:51
  • If you want to add a password/passphrase to the private key, just add -P. E.g. puttygen k.pem -PO private -o k.ppk.
    – CPHPython
    Nov 11, 2018 at 10:52
  • For me it worked from command line!
    – achasinh
    Apr 23, 2021 at 12:47
15

If you are using GNU/Linux, you don't have to use Putty. That part of the tutorial is geared towards Windows users.

Just set your .pem file permissions to r-- by doing chmod 400 mykey.pem then you can pass it straight to ssh :

ssh -i mykey.pem user@aws-host.amazon.com 
3
  • The reason I am trying to use putty is so I can follow the instructions in this plex tutorial. If there are other ways of doing it, then please feel free to explain. Feb 21, 2014 at 16:47
  • Your Plex Media server is on the AWS machine and you're trying to tunnel to it from your Mint workstation, am I getting this right ? You should open another question explaining this, but there are already many questions explaining how to do SSH tunneling. Feb 21, 2014 at 16:57
  • 1
    By using the command that you mentioned i was able to login in to the remote AWS instance. I actually wanted to transfer files i used the command (just in case it helps someone) sftp -oIdentityFile=mykey.pem user@<publicIP> ... thanx your post helped me solve the problem i was having for more than 5 hours. Jan 6, 2015 at 9:25
0

use the below command its worked for me in ubuntu

puttygen /home/abc/Downloads/dockerkey1.pem -o home/abc/Downloads/dockerkey1.ppk -O private

Example

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

2
  • This is already described in the accepted answer. You don’t need to use sudo for this, if your current user has write permission in the output directory. Aug 7, 2019 at 8:59
  • Thanks For your Suggestion @Stephen kitt
    – thrinadhn
    Aug 7, 2019 at 9:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.