is / jsch

Mirror of JSch from JCraft.
Other
383 stars 190 forks source link

Public key authentication #12

Open hazzelbanger opened 6 years ago

hazzelbanger commented 6 years ago

I am attempting to connect to the SFTP server using public key authentication. To do so I need to call JSch.AddIdentity() and pass in the private key.

The private key I need to use is stored in a Java KeyStore object. When the key is retrieved from the KeyStore it is a PrivateKey type. From trawling the internet it appears the private key is in the DER format.

What format is required for AddIdentity()?

I have searched for examples of converting the PrivateKey to a PEM string which is equivalent to the contents of a private key file used by SSH. But no luck so far.

Plazmaz commented 6 years ago

Believe this is PKCS8 (or PKCS1, can't remember for sure).