How to get your private and public OpenSSH keys from a putty key

The .ppk format for private keys created by puttyGen  for use with pageant is very portable for sharing and as such, you find yourself moving it around often. This then usually leads to a problem , which is converting it to the OpenSSH format that is required by most tools you wish to integrate with.

To, export your .ppk to the OpenSSH format and also get copies of your private and public key, follow the steps listed below.
puttygen supports exporting your private key to an OpenSSH compatible format. You can then use OpenSSH tools to recreate the public key.

  1. Open the tool PuttyGen and do the following
    – Click Load and then select your .ppk file
    –  Click the Conversions menu and then click Export OpenSSH Key
    – Save the key with any filename you wish  (usually ~/.ssh/id_rsa)
  2. Use ssh-keygen to get the RFC 4716 version of your public key from the exported private key using the command given below
    ssh-keygen -e -f ~/.ssh/id_rsa > ~/.ssh/
  3. Use ssh-keygen to convert the RFC 4716 version of the public key to the OpenSSH format:
    ssh-keygen -i -f ~/.ssh/ > ~/.ssh/