满意答案
session.connect();之前看看password设置了么?
if(ua!=null){
auth_cancel=false;
try{
auth=ua.start(this); if(auth &&
JSch.getLogger().isEnabled(Logger.INFO)){
JSch.getLogger().log(Logger.INFO,
"Authentication succeeded ("+method+").");
}
}
catch(JSchAuthCancelException ee){
auth_cancel=true; }
catch(JSchPartialAuthException ee){
smethods=ee.getMethods();
smethoda=Util.split(smethods, ",");
methodi=0;
//System.err.println("PartialAuth: "+methods);
auth_cancel=false;
continue loop;
}
catch(RuntimeException ee){
throw ee;
}
catch(Exception ee){
//System.err.println("ee: "+ee); // SSH_MSG_DISCONNECT: 2 Too many authentication failures
break loop;
}
}
}
break;
}
if(!auth){
if(auth_cancel)
throw new JSchException("Auth cancel"); throw new JSchException("Auth fail");
}
[/color]
另见UserAuthPassword 中
[color=red] if(!userinfo.promptPassword("Password for "+dest)){
throw new JSchAuthCancelException("password");
//break;
}
String _password=userinfo.getPassword();
if(_password==null){
throw new JSchAuthCancelException("password");
//break;
}
00分享举报