Convert SSH private key with PuTTY keygen

This tutorial will show you how to convert SSH private key with Putty keygen.
It is silly, but SSH2 private keys do not have standard format. OpenSSH, ssh.com, PuTTY have different formats, and any key generated with one client cannot immediately be used with another.

For example in my tutorial create and use SSH key under linux we have discussed how to create key pair using ssh-keygen tool. My private key was looking like this:

If I just copy and paste it in a file and include it when I am using PuTTY I will receive an error saying: ‘Server refused our key’

So save your key in a simple text file using Notepad. In order to have this key converted, you can use PuTTY keygen to import and save the key in appropriate format.

If you do not have PuTTY keygen tool, you may download it from http://putty.nl .
Usually it comes along with PuTTY package so if you have it installed it should be inside C:\Program Files\PuTTY .

Anyway, open it and click on ‘Conversions’ and then ‘Import key’, locate the text file you saved and open it.

Convert SSH private key with PuTTY keygen

PuTTY keygen imports such key like this:

Convert SSH private key with PuTTY keygen

Now simply click on ‘Save private key‘, choose a location and click save.
The new key will look rather different:

Now, load your PuTTY client and at left for category click on ‘Connection’ ‘“ ‘SSH’ ‘“ ‘Auth’. There under the section ‘Authentication parameters’ locate ‘Private key file for authentication‘, and browse for your new key.
The next will be to connect to your server.

Tags

Filed Under: SSH

Anthony Gee About the Author: Anthony G. is an IT specialist with more than 9 years of solid working experience in the Web Hosting industry. Currently works as server support administrator, involved in consultative discussions about Web Hosting and server administration. One of the first writers in the Onlinehowto.net website, now writing for Free Tutorials community - he is publishing tutorials and articles for the wide public, as well as specific technical solutions.

Comments (3)

  1. Anthony Gee Rashid says:

    I was shaking my head for a while, why I cannot connect with putty to my linux server, and this tutorial helped me.
    Thanks!

  2. RubenBCR says:

    Something that was driving me crazy: if you are getting “not a private key” errors when trying to import the text file you created, make sure you don’t have any extra spaces or lines in your document, it has to start with

    ‘”’“BEGIN RSA PRIVATE KEY’”’“

    And finish with

    ‘”’“END RSA PRIVATE KEY’”’“

    Be very strict about this and try again, worked for me (after several self inflicted corporal punishment attempts).

Leave a Reply