home | advisories | code | downloads | robanukah | contact

.: Converting PuTTY puttygen private keys to work with OpenSSH

Okay so I have finally given up on Vista (which was OEM preinstalled). Time to switch back to Linux :)
Anyways I have a private PuTTY key file, created using the 'puttygen.exe' utility. The key also uses a passphrase for additional security. Here is the format:

PuTTY-User-Key-File-2: ssh-dss
Encryption: aes256-cbc
Comment: First Last
Public-Lines: X
<removed>
Private-Lines: X
<removed>
Private-MAC: <removed>

I tried to use:

$user@host:~/$ ssh -i ~/.ssh/private.key site.com -p 22
Enter passphrase for key '/home/user/.ssh/private.key':
Enter passphrase for key '/home/user/.ssh/private.key':
Enter passphrase for key '/home/user/.ssh/private.key':
user@host.com's password:
Permission denied, please try again.

As you can see, ssh is asking for the passphrase but it still cannot read the decrypted key.

I had a look on Google but came up empty handed, so I resorted to installing PuTTY for Unix (Linux).

# apt-get install libgtk1.2-dev
$ tar xvhf putty-0.60.tar.gz
$ cd putty/unix
$ make -f Makefile.gtk
$ ./puttygen --help
PuTTYgen release 0.60
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'

Great! All we need to do is convert the key!

$ ./puttygen ~/.ssh/private.key -O private-openssh -o ~/.ssh/new-private.key
$ ssh -i ~/.ssh/new-private.key site.com -p 22


Top of Page.