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.
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?
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?
SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog