Ubuntu – How to convert Filezilla PPK to openssh sftp compatible key

filezillaopensshsftpssh

I'd like to use the command line sftp client and sshfs and have been given a filezilla ppk file. How do I extract the keys into a format that works with sftp, openssh?

I tried just copying the portions out of the ppk and into a private pem file but it didn't work. Running openssl rsa -in keyfile.pem on it shows that it's not an RSA key.

unable to load Private Key 140462727153304:error:0D0680A8:asn1
encoding routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1197:
140462727153304:error:0D07803A:asn1 encoding
routines:ASN1_ITEM_EX_D2I:nested asn1 error:tasn_dec.c:374:Type=RSA
140462727153304:error:04093004:rsa routines:OLD_RSA_PRIV_DECODE:RSA
lib:rsa_ameth.c:119: 140462727153304:error:0D0680A8:asn1 encoding
routines:ASN1_CHECK_TLEN:wrong tag:tasn_dec.c:1197:
140462727153304:error:0D07803A:asn1 encoding
routines:ASN1_ITEM_EX_D2I:nested asn1
error:tasn_dec.c:374:Type=PKCS8_PRIV_KEY_INFO
140462727153304:error:0907B00D:PEM
routines:PEM_READ_BIO_PRIVATEKEY:ASN1 lib:pem_pkey.c:141:

How do I do this?

Best Answer

Thanks to the comment from Spas Spasov (@pa4080) I did get it going.

This is what I did.

matthewh@xen:~/.ssh$ puttygen
The program 'puttygen' is currently not installed. You can install it by typing:
sudo apt install putty-tools

matthewh@xen:~/.ssh$ sudo apt install putty-tools
...

Finally I needed to read the man page to use puttygen to convert the ppk.

The command to perform the conversion was:

puttygen keyfilename.ppk -O private-openssh -o keyfilename.pem

Then I was able to use the key for ssh/sftp and sshfs.