jsch icon indicating copy to clipboard operation
jsch copied to clipboard

Public key authentication

Open hazzelbanger opened this issue 7 years ago • 1 comments
trafficstars

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.

hazzelbanger avatar Feb 20 '18 04:02 hazzelbanger

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

Plazmaz avatar Nov 12 '18 05:11 Plazmaz