Create and Convert Key Files with Putty

The Putty tool suite comes with a quite handy tool named “puttygen”.

The tool can be used to create a new key pair. When saved to disk, the private key is written by default in Putty’s PPK format, which contains public and private key:

 PuTTY-User-Key-File-2: ssh-rsa
 Encryption: none
 Comment: rsa-key-20151024
 Public-Lines: 6
 AAAAB3NzaC1yc2EAAAABJQAAAQEAyvBSF7UZiR3xD8VlsRYmPCZxtwTWqxTLXiZ4
 :
 IJN9hvFUKQOwgwgOmmueN4p4xEWS/R+3M8hYgi8RXT9Ft/y41w==
 Private-Lines: 14
 AAABAQCJHutcIGszIhGVCNYCCAv/IOUM9W5zmG28J9TyrHmJQH39XVsfmsrVrbLz
 :
 Wa1ln3a4oRKMI9yy9OPfo3umjI9tejbrd5z9nx8CtXWapsWD
 Private-MAC: fd2ba6453510156b1f3b3e9a657faa33449b8056

The format is however mostly not recognized by applications other than Putty, for instance OpenSSH used on Linux or OS X.

The good thing is that the tool allows to export the private key in various file formats. It is also possible to load an already existing private key and perform a conversion. This is very handy when using your key files on PC/Windows and Mac/OSX.

Under Windows, this would look like this:

Out comes a nicely formatted OpenSSH key file, as defined in RSA’s RFC 3447:

 -----BEGIN RSA PRIVATE KEY-----
 Proc-Type: 4,ENCRYPTED
 DEK-Info: DES-EDE3-CBC,B2F2165999A20945

 BYgPZGv+rOYnXJjbhxjXodoAdGCYR6cpQ4Y0TsZLa5VTf3l2yTJgecnMqm2zf7Fj
 :
 WREZBosmGV44rzNEYzQHP/AiRed9P2iBOwNp2l9pAlIFxEXCidU2Ew==
 -----END RSA PRIVATE KEY-----

 

NB. The tool suite can also be used on Linux or OSX:

Install:

  sudo apt-get install putty or brew install putty

Then, command-line style:

  puttygen ...

Leave a Reply

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