We have been asked to connect to an SFTP server using an RSA public key.
I generate the keys using the Java Keytool and store them in a Java Key Store (JKS)
How do I access and use the private key?
Chilkat now has a JavaKeyStore object. See the online examples and reference documentation. This answer (below) is no longer the easiest solution...
The solution is to export the key to another format, such as PEM (PKCS8) or .p12 (PFX). This StackOverflow web page shows how to convert to PEM: http://stackoverflow.com/questions/652916/converting-a-java-keystore-into-pem-format
The Chilkat classes can be used to convert keys to virtually any format.
To use the private key with Chilkat SSH/SFTP, it needs to be imported into a Chilkat.SshKey object (or depending on the programming language it may be CkSshKey, CkoSshKey, etc.)
The SshKey object can import private keys from:
1) OpenSSH private-key file format
2) PuTTY private-key file format
3) XML format, which is Chilkat specific.
The Chilkat.PrivateKey class an import RSA keys from the following formats: PEM, PKCS8, binary DER, PVK, and XML.
The Chilkat.PrivateKey can export to all of these formats as well.
Here's the procedure to get the Java Key Store private key into a Chilkat.SshKey object:
1) Follow the instructions in the StackOverflow article to export the private key from JKS to PEM.
2) Load a Chilkat.PrivateKey object with the PEM.
3) Export from Chilkat.PrivateKey to XML.
4) Load the XML into a Chilkat.SshKey object.
Chilkat now as a JavaKeyStore object. See the online reference documentation and examples..