获取ChannelSftp时,我们得到 jcraft.jsch.JSchException:verify:false 。现在,它经常发生。
以下是我收到此错误的环境。
java version "1.7.0_10" and 1.7.0_13
weblogic 11g(10.3.6.0)
jsch jar version jsch-0.1.50.jar
有关如何解决此问题的任何建议都非常有用。
ChannelSftp sftpChannel = null;
JSch jsch = new JSch();
Properties jschConfig = new Properties();
jschConfig.setProperty("compression.s2c", "none");
jschConfig.setProperty("compression.c2s", "none");
jschConfig.setProperty("StrictHostKeyChecking", "no");
jschConfig.setProperty("PreferredAuthentications", "publickey,password");
JSch.setConfig(jschConfig);
Session session = null;
try {
jsch.removeAllIdentity();
jsch.addIdentity(privateKeyFile);
session = jsch.getSession(user, host, port);
session.connect();
} catch (JSchException e) {
throw new RuntimeException("Failed to connect to " + host, e);
}
sftpChannel = (ChannelSftp) session.openChannel("sftp");
sftpChannel.connect();