3

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?

muru
  • 197,895
  • 55
  • 485
  • 740
hookenz
  • 2,579
  • 1
    .ppk means 'PuTTY Private Key' try to covert it with 'PuTTY Key Generator' as it is described here. – pa4080 Apr 12 '17 at 23:24
  • 2
    Not sure if it's mentioned in the linked answers, but the putty-tools package provides a Linux implementation of puttygen if you don't have access to a Windows system – steeldriver Apr 12 '17 at 23:33
  • Yes this information is not provided in the above reference, I just looking for Linux package :) By the way PuTTY for Windows works pretty good with Wine. – pa4080 Apr 12 '17 at 23:45
  • 1
    Thanks guys, I got it working. Guess I'll put an answer with the commands for linux. – hookenz Apr 12 '17 at 23:48

1 Answers1

3

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.

pa4080
  • 29,831
hookenz
  • 2,579