I need to to make an SFTP connection to an SFTP site with the SSH2 mode using Java code in PL/SQL developer.
And the connection requires an RSA key to start with. We got the RSA key, but I have some trouble with the code.
Below is the code I've got so far, and I don't know how to turn on the SSH2 mode, and I don't know how to include the RSA key:
public static void SFTP_Login (java.lang.String inSite, int inPort, java.lang.String inUser_ID, java.lang.String inPassword)
The inSite in my code is an SFTP site xx.xxx.xxx.xxx, and there is a login/username, but no password for this site. Password is blank. And where I was given was an RSA key (a .ppk file)
My problem right now is, using the java code I showed you, I got an error saying there is a problem with login. I wasn't able to login if I run my code.
And I figured it must be the RSA key, since I am not using it when I do the login part, and this private key is needed. So you mentioned that it's going to be in SSH2 mode automatically,
then maybe the reason it's failing is due to the RSA key. But I don't know where to use this key in my Java code.
Should I do something like this?
KeyFactory f = KeyFactory.getInstance("RSA");
1) From the imports you are probably using Orion SSH library and you should not need any other SSH libraries to do SFTP operations.
2) The code you originally posted only authenticates using (username, password) and RSA is not involved. As I said before you need to look at the examples that come with the Orion library. One of the examples uses RSA.
3) I'm pretty sure, but not certain, that the 'ppk' file cannot be used directly by Orion and will need converting to the standard SSH private key format. Putty generates 'ppk' files and you can perform the conversion using Putty.
I looked at the RSA example, and I changed my code to use the RSA key.
And as you said, the ppk doesn't work, I need to convert to PEM format.
After some research, I think I need to use the Java class called CkSshKey ( and I imported the library com.chilkatsoft.*), but the problem is that I can't compile the Java
code, it says this CkSshKey is not found.
My question is do you know which java library I should import in order to support this? Or is this CkSshKey java-version specific?
The only reference to class Java class CkSshKey I can find is http://www.chilkatsoft.com/refdoc/javaCkSshKeyRef.html but I doubt if this is what you want since it is part of a complete Java SSH library which look to involve a native library.
Did you try converting the key using Putty? I haven't done if for some time but I remember it was not difficult.