Hello All,
I am using jsch-0.1.43.jar in my project. And my server has FSecure
bash-3.00$ ssh -V
ssh: Reflection for Secure IT 6.1.3.0 (build 3077) on sparc-sun-solaris2.10
(32-bit)
The private key generated looks like :
---- BEGIN SSH2 ENCRYPTED PRIVATE KEY ----
Subject: user
Comment: "2048-bit rsa, user@host, Wed Jan 26 2011 01:02:42 -050\
0"
When I try to execute a program remotely it is failing with following
exception:
bash-3.00$ com.jcraft.jsch.JSchException: invalid privatekey:
/home/user/.ssh2/id_rsa_2048_a
at com.jcraft.jsch.IdentityFile.<init>(IdentityFile.java:261)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:135)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:130)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:206)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:192)
I debugged this issues and figured that Jsch is failing in IdentityFile.java
program
part of IdentityFile.java prog
private IdentityFile(String name, byte[] prvkey, byte[] pubkey, JSch jsch)
throws JSchException{
this.identity=name;
this.jsch=jsch;
try{
Class c;
c=Class.forName((String)jsch.getConfig("3des-cbc"));
cipher=(Cipher)(c.newInstance());
key=new byte[cipher.getBlockSize()]; // 24
iv=new byte[cipher.getIVSize()]; // 8
c=Class.forName((String)jsch.getConfig("md5"));
hash=(HASH)(c.newInstance());
hash.init();
byte[] buf=prvkey;
int len=buf.length;
int i=0;
while(i<len){
if(buf[i] == '-' && i+4<len &&
buf[i+1] == '-' && buf[i+2] == '-' &&
buf[i+3] == '-' && buf[i+4] == '-'){
break;
}
i++;
}
while(i<len){
...
My key has only four '-' characters at the start of key, but the program is
checking for five '-' characters in the first while loop. Eventually it is
setting value of i to lenght of the byte array. and it never when into the
second while and didn't find the key type and failing with Invalid Key
exception.
Please if you need my complete program, it can be found at
http://techpalli.blogspot.com/p/jsch-api.html
Thanks,
RK.
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
JSch-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jsch-users