com.jcraft.jsch.JSchException:com.jcraft.jsch.Session.receive_kexinit 算法协商失败(来源未知)

问题描述 投票:0回答:1

我正在尝试连接到我的一台 unix 服务器,但失败并出现上述错误,有人可以帮忙吗。

JSch jsch = new JSch();

java.util.Properties configuration = new java.util.Properties();
configuration.put("kex", "[email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1, diffie-hellman-group1-sha1");
configuration.put("StrictHostKeyChecking", "no");

Session session=jsch.getSession(user, host, 22);
session.setPassword(password);

session.setConfig(configuration);
session.connect();
java algorithm jsch
1个回答
0
投票

可能无法每次都更改目标服务器上的某些设置。 我在使用“com.jcraft.jsch_0.1.27.jar”时遇到了类似的问题,但在尝试使用最新版本(即“jsch-0.1.54.jar”)后,我没有遇到此问题。

此外,此 SFTP 可能会以交互模式打开,即询问用户名和密码,在这种情况下,需要按 Enter 键才能继续。为此,以下是解决方案:

config.put("PreferredAuthentications", "publickey,keyboard-interactive,password");
config.put("StrictHostKeyChecking", "no");
session.setConfig(config); 
© www.soinside.com 2019 - 2024. All rights reserved.