SFTP implemention with Jcraft -- Advise needed on authentication with certs

Hi All,

We are implementing SFTP in wM 7.1 using jcraft.
I could write the java service to logon to SFTP server with username/pwd authentication.

But, I need authentication with both certs and username/pwd.
Could any one please help me out here how I can write java code for this with jcraft SSH.


Why do you need java code for this? can’t you use pub/ftp services (with sftp mode) and certificates configured?


Firstly, thanks a lot for looking into my thread.

I am a bit confused with your post here.
I read that wM do not support SFTP out of the box and it only supports FTPS from V 6.5.
This is the reason why we are considering jcraft to implemeny sftp in wM.
we could logon to sftp server with a piece of java code using jcraft ssh and authentication being username/pwd.

Could you please more elaborate on your post.

“can’t you use pub/ftp services (with sftp mode) and certificates configured?”

Do you mean wM supports sftp?
I believe/read that pub/ftp service works in ftps mode and not in sftp mode.
If I have to use public key also along with the username/pwd for authentication while logging in to sftp server, what we have to do?
I thought that we need to write java service similar o wht I wrote to logon to sftp server (wuth being username/pwd).
As I could not succeed in writting a java code for public key authentication, I reached out to t he forum.

Please correct me if I am heading in a wrong direction.


Hi Venkat,

I have written the java code (JCRAFT JSCH) to put file via SFTP using both password and public/private key authentication from a same java service.

Let me know if you need it now.



Hi Arpith,

It would be of great help if you can kindly share your java code with me.


Hi Venkat,

PFA the code …

Input of the service:

pathFileName: basically source path where the file is existing.
destpath : destination path
destFile : filename you want to be put intop the location
prvKeyPath: path where you have your private key
prvKeyPassPhrase: if you have any passphrase setup for private key

let me know if you see any issue as this code is working perfectly in my project and is a part of the framework.


JSCH.txt (3.16 KB)

Hi Arpith,

Thanks a lot for the quick reply.
I will go through the service and will come back if I face any issues.

And Arpith, Could you please let me know your thoughts on the below scenario of ours.
We have a requirement to implement SFTP in webmethods 7.1.2 and we suggested our client to use jcraft jsch and told the client that this is an open source software. Now, our client is insisting not to use open source software as they are seeing a risk of getting no technical support in case of any issues with open source softwares. So, they insisted to go for a licensed software to implement sftp in wM. We did a little research and selected ws_ftp tool.
Could you please let me know your thoughts on this, like, how risky is using open source softwares such as jcraft and feed back on ws_ftp tool if you have any idea on it.


Hi Venkat,

I don’t see any major drawbacks of using Jcraft JSCH … apart from getting technical support which still I feel the Java experienced guys can help you with that as lot of code is available on net.

My client have a huge webMethods implementation and they don’t feel any issue with using open source softwares…

I personally don’t have any experience on using ws_ftp tool so can’t comment on that …

Hi Arpith,

I am very new to webMethods. I was created a java service by using the code you are providing. I am getting the following error while saving the service.
"cannot find symbol
symbol : method addIdentity(java.lang.String,byte[],,byte[])
location: class com.jcraft.jsch.JSch
jsch.addIdentity( "

I know some where I did a mistake, Please guide me to achieve this.

Thanks in Advance

Dear vsomu,

Welcome to webMethods world … and u will have a nice time working on webMthods platform …

I am not much experience on Java but here You have not imported the jsch jar files into webMethods IS. Please import the jars and compile your code again …

cheers …

Hi Arpith,

In the email thread you say - “I have written the java code (JCRAFT JSCH) to put file via SFTP using both password and public/private key authentication from a same java service.”

I am also implementing the exact same thing and would very much appreciate being able to check out your source code on this. So please send me a copy to joneyre@att.com

Thank you very much.

Regards Jon

Hi Arpith,

Need your assist to brief me your java code below. I’m newbie to webMethod also and now i need to do FTPJobs to connect sFTP server with only Private Key File provided. I have tried your Java Code provided, but i can’t get any result returned for ChannelSftp, SessionFactory & status.

May i know what is “PassPhrase” in below? Is that means password for the UserID? And for privateKey, what value i should input? Is that the location path of the PrivateKey file?

	   ftpUserName,    // String userName            
	   prvkey,         // byte[] privateKey             
	   null,            // byte[] publicKey            
	   PassPhrase );  // byte[] passPhrase

Look forward your assist reply. I’m urge to complete the FTPJobs :wink: Thanks very much on this.
or you can email me to nicholaz4u@gmail.com

If you are using WM 9.0 or newer, SFTP is supported natively (check pub.client.sftp folder).

If you are using older version, jsch is easy to implement.

Passphrase is used to secure your SSH key, when you generate the SSH key, you give a passphrase.

Hi Tong Wang,

Thanks alot of your guideline reply at here. Sorry for my late reply because busy on some other works.
The code wasn’t run from my platform, i not able get sFTP connection result.
I’m using webMethod ver 8.2 SP1.

I have hit with error on below, may i know what value should i give for privateKey? Is that the full path pointed to the Private Key that i have stored at (can give example)?

	   ftpUserName,    // String userName            
	   prvkey,         // byte[] privateKey             
	   null,            // byte[] publicKey            
	   PassPhrase );  // byte[] passPhrase

Currently in my webMethod has one sFTP module (BW_Utilities.ftp.sftp:login) which is only serve for (Host, Port, UserName & Password), but then for my project i only allow to use Private Key connection due to security reason. Hope my doubt here can be solve. Very much appreciate your help.

Below is the error that i have when i tried with

D:\WM8_2\IntegrationServer\packages\BW_Utilities\code\source\BW_Utilities\ftp\sftp.java:482: unreported exception com.jcraft.jsch.JSchException; must be caught or declared to be thrown
1 error

If I remember correctly, there are a few addIdentity methods you can call. one of them:
jsch.addIdentity(privateKeyFile, publicKeyFile, passPhrase
which you should provide the file path for both private key file and public key file.
Note the key should be a RSA key.
you can use PuttyGen to generate a pair of public/private key with given passphrase
puttygen can be downloaded from:

for your error, you need to have a try-catch around your code, and catch JSchException


a bit late, but just some remarks to sort things out:

FTPS is not equal to SFTP.
FTPS uses FTP protokoll SSL for transport and SFTP uses SSH protocol for transport.


FTP (and FTPS) have been supported by webMethods quite early, but SFTP has been introduced with 9.x incorporating a SAG Consulting solution which was known as WmSSH2 Package.


Hi wm_member,
can you please send me copy of jar (JCRAFT JSCH) to yac.bouider@gmail.com or tell me where i can dawnload it?
I’me using IS 10.3 but the same problem, we can’t use both SSH key and password user

I finaly found jar com.jcraft.jsch_0.1.27.jar, i have another problem
can you please, tell me what is pub.CommonUtils, is there any jar for that?


pub.CommonUtils is part of WmPublic. you can find it under: IntegrationServer\packages\WmPublic\code\classes\pub