7

I have a private key private.key) in format -----BEGIN RSA PRIVATE KEY-----IEpAIBAAKCAQEAvKwuhMiQR/THmjK.....-----END RSA PRIVATE KEY-----, and I am trying to convert it in the format that putty (.ppk) understands using ssh-keygen command through cygwin, but i am getting a public key instead. Do I need to save the original file (private.key) in any specific format?

I tried saving the (private.key) in .pem format and no extension. Tried ssh-keygen -t rsa -e -f private.key > privatekey2.ppk Tried ssh-keygen -t rsa -i -f privatekey2.key Tried ssh-keygen -p Expecting the key in below format:

Comment: imported-openssh-key
Public-Lines: 6
AAAAB3NzaC1yc2EAAAADAQABAAABAQCiud9bCgiaSX7ck2Y1orbH3U5+4lsOmAbT
Az361YM3XwX6nLNyPycFkTdYfX75IhUPCT9ywPm4WvEy9B78qL6EoKZctAM/DUZA
7DDJeeK4NWsulN4qDUyWoR50wVJCswgwMLCZPwcXeyed8WpUi2qbi8Di4KJphdtV
HIAeq2pDYaj1HMBtxI2Lrd5DPSt7u28v/twrOksDpSA7DXzRu7AsIKvO/dF9/PR4
WB/cqctC9RPvDK1VWNj+xPFGZ2ylBr0aC3TilbKaou/8S2AmJyp5FOGUEBCUMGWs
P/fQbN0XQX6dQuvfTtYUBf4ZuJKxhPDBKiacUg5YufXdNR3I/JIx
Private-Lines: 14
AAABACLXmqgDG3lxsCypkPJ+DxX3YFXRwL58tcVbxdsd+XUTLxQMlm2pcQEDqW6U
nGnartij2caH5FBhhJCs7a+asAR043oo/yLyhC7lg8K4Ct/3bCYysOkfJN2BzSQh
uqvWarPq0P1XHf0chidx4AxTsLxz0DQ5nG89tXlu4eQRYHq4jdR5Pkr5wWHjYzpX/
o9C3bcgSlKqFVJMnw06eUI6c1STtQAj/Tn+1wLpTS+p3P7kO6oXXwAKU6kOnjbx5
S0u4XUY+ZKTlhrY24zbXhGPliGDyaTL8387AE1cqWAJeWenAlbIxRzy13BQ/8RNe
hpmLaHhCz32d+BFc4Oav3GyxibkAAACBANA8e5hWJOGnbSIugrWrkDGuSTQp1BFi
rYEaxml69w8QmsY2s5kzLXvuWPIZCUzMv1XjHJxsa8LmzwZ/tdKKfcfQILRT54Oe
NHkznPj4LgwsmVw+8WyCoA8sOykZ+tIOtwpEQUzBEGCPrMR/tsg3qigvbnno9daT
BdOTiYFbowQVAAAAgQDIDQ5qRRWuyu0broHDoB0JozFPUvIDZfIwfjWqVQqgjO5HG
I4kIKCS5JYC2HDtgb8t7f841hKvLzitmRiswZr5koEKBOrZTxPhI6CNBtZPTgFfV
ipJHukDSkZxzxlaG52bc1NxqXh8Q6XZFiURQ36JbQtWmCLQTFC2vRXOMEiuQrQAA
AIEAxo+trWXMfn7W21wMCEXDTtX5ciZMPupIoUjZ/rmRxVLSI5PmJDJS549UmVWy
Q8bnU9rFgc7dG/ZuB4HD+iVSpFDhkovGCE8a2DF47Bu100bOVPIH3o7KxfWFCtzh
Yw/KqweHiU1iUwuC4FUIxJW8jyxv2sOmxbOgZCZ7WNm8Qvo=
Private-MAC: 22f55dc7c54402157df04950dsf67d8473bb5476f```
2

1 Answer 1

9

You cannot do this with OpenSSH's ssh-keygen; it can neither import nor export PuTTY's key format.

(Your -e and -i options don't work because they have absolutely nothing to do with PPK. The manual page actually says it'll output RFC4716 format keys, which is a very different thing.)

To make a PuTTY PPK file, you need puttygen:

$ puttygen private_key.key -O private -o private_key.ppk
11
  • Thanks for the quick response Grawity, no the manual, just says RFC4716 key format for private key. Can we use puttygen on cygwin? Commented Jul 16, 2019 at 5:36
  • Yes, PuTTY and its tools are available for all Linux/Unix systems, so they should work on Cygwin as well. (I don't know if there's a package or if you need to compile manually.) Commented Jul 16, 2019 at 5:38
  • Of course, if you only want a one-time conversion (instead of an automated method), you could just use the Windows version (puttygen.exe) – it can import OpenSSH private keys through the menu. Commented Jul 16, 2019 at 5:39
  • No, cygwin doesnt have package for puttygen. No, want to do it through command line in shell script, so can't use windows version. Commented Jul 16, 2019 at 5:53
  • 1
    @pratiksharma+ the ssh-keygen man page is no longer as clear as ut used to be but RFC4716 is a file format for public key only, not private. Commented Jul 16, 2019 at 6:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .