8

I have generated a key for an Ubuntu Virtual Machine running on Azure Cloud Services http://www.windowsazure.com/en-us/manage/linux/how-to-guides/ssh-into-linux/

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout myPrivateKey.key -out   myCert.pem

When loading the private key into Filezilla, it asks me to convert the format, however, when converting the key it fails, the same happens with puttygen from linux console, using this:

puttygen myPrivateKey.key -o myKey.ppk

In both cases I have the following error:

puttygen: error loading `myPrivateKey.key': unrecognised key type

By the way, this key doesn't have a passphrase.

I found an old thread about it, but I'm using 0.6.3 version which is newer than what this thread recommends:

http://fixunix.com/ssh/541874-puttygen-unable-import-openssh-key.html

I've managed to solve this issue by using another gui client Fugu for Mac, but one of my co-worker uses windows and I still have to figure this out.

Since Filezilla is the de-facto ftp client, I thought it would be easier to solve it there.

Thanks

raul782
  • 181
  • 1
  • 1
  • 3

4 Answers4

5

puttygen understands openssh keys, not SSL keys. You need to generate an ssh key pair using ssh-keygen(1), then puttygen will convert the private key into its .ppk format.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47
  • Ok, but in the case of a azure cloud service, they require you to use ssl key, is there a way to convert ssl key to ssh key and then to ppk format? – raul782 Jan 05 '14 at 06:33
  • Hm, it seems that they're basically the same - they're both RSA private keys. But they may have different header and footer lines. If your key file doesn't begin with `-----BEGIN RSA PRIVATE KEY-----` and end with `-----END RSA PRIVATE KEY-----`, try replacing just those header and footer lines, and see if puttygen will accept it. – Andrew Schulman Jan 05 '14 at 06:45
  • It didn't work, the error is : puttygen: error loading 'myPrivateKey': ASN.1 decoding failure – raul782 Jan 05 '14 at 06:55
  • Yeah, this is very odd. All the docs say that an openssl private key should work as an openssh private key, and in my testing ssh did accept one. But ssh-keygen and puttygen both refuse to accept them for conversion. – Andrew Schulman Jan 05 '14 at 07:33
  • Which keytype did you give when creating the key with `ssh-keygen`? Was it `ed25519`? PuTTYgen only imports keys with certain encryption types, `rsa` for example. – twigmac Jun 30 '16 at 08:19
4

changing the password, as sugggested above, worked for me. I changed the password

ssh-keygen -p -f private_keyfile
then tried again to use puttygen to create a ppk file and it was successful.

puttygen private_keyfile -o private_keyfile_for_putty.ppk

before changing the password I got an error
"puttygen: error loading `rate_notices_key': unrecognised key type"

using puttygen on both windows and my FreeBSD vm. thanks for that, I searched high and low before finding your answer. Sure, I could have just created a new key pair with puttygen, but having used ssh-keygen and submitted the public key to a vendor for an account to access a secure ftp site, I wanted to use the private key I already had.

andrew perry
  • 106
  • 3
1

Try this ssh-keygen -m PEM -t rsa -b 4096 -C "your_email@example.com".

this will force to add the header like

-----BEGIN RSA PRIVATE KEY-----

instead of

-----BEGIN OPENSSH PRIVATE KEY-----
NathanielR
  • 21
  • 1
0

After setting passphrase using ssh-keygen, the ssl key is converted to ssh private key then can be recognized by puttygen.

Andrew Schulman
  • 8,811
  • 21
  • 32
  • 47