com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Session.java:460)
at com.jcraft.jsch.Session.connect(Session.java:154)
at cn.vivame.util.ftp.SftpServerAccess.connect(SftpServerAccess.java:100)
session.connect();之前看看password设置了么?
if(ua!=null){
auth_cancel=false;
try{
[color=red] auth=ua.start(this); [/color] if(auth &&
JSch.getLogger().isEnabled(Logger.INFO)){
JSch.getLogger().log(Logger.INFO,
"Authentication succeeded ("+method+").");
}
}
catch(JSchAuthCancelException ee){
[color=red] auth_cancel=true;[/color] }
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){
[color=red] if(auth_cancel)
throw new JSchException("Auth cancel");[/color] throw new JSchException("Auth fail");
}
[color=red][/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;
}[/color]
也用jsch的sftp,没遇到类似为题。建议贴代码看看
请问该问题是否跟内网环境有关系?我这边通过两层代理访问报该异常。
com.jcraft.jsch.JSchException: Auth cancel
at com.jcraft.jsch.Session.connect(Session.java:511)
at com.jcraft.jsch.Session.connect(Session.java:183)
at com.chinainsurance.application.prpall.infsystem.fileutil.sftp.SFTPChannel.getChannel(SFTPChannel.java:59)