使用jschexception验证false的SFTP有时会失败

时间:2014-01-15 09:10:19

标签: jsch

获取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();

0 个答案:

没有答案