File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Security and the fly likes Jsch Passphrase Query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Security
Bookmark "Jsch Passphrase Query" Watch "Jsch Passphrase Query" New topic
Author

Jsch Passphrase Query

Jiss Elizabeth
Greenhorn

Joined: Jul 28, 2004
Posts: 19
Hi,

I am using Jsch and so far ssh worked great for my application. Now that i have added key chain and trying to log on to my server without password it is asking for passphrase which is already stored using ssh key agent. How can i make jsch read passphrase from the key file? Is there a way to do this. Would be great if you could help me out with this.

Thank You!

-- Jiss
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Use com.jcraft.jsch.KeyPair.setPassphrase()?


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Jiss Elizabeth
Greenhorn

Joined: Jul 28, 2004
Posts: 19
Hi,

I am using Mac 10.5. When i open a terminal and ssh to my server it directly logs on to server without asking me for the passphrase as it is added in Mac's Key Chain. But when i run my application which uses jsch it always prompts for the passphrase. This is my code.

JSch jsch = new JSch();
jsch.addIdentity(x.getKeyChainPath());
session = jsch.getSession(x.getUsername(), hostname, port);
session.setPassword(remoteData.getPassword());
localUserInfo lui = new localUserInfo();
session.setUserInfo(lui);
session.connect();

How i can i make jsch read passphrase from keychain?

Thank You!
--Jiss
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

I'm not sure if Jsch can work with ssh-agent. It's been a while since the last time I used Jsch. BTW, there is a method jsch.addIdentity(String privateKey, String passphrase). Why don't you use that instead?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Jsch Passphrase Query