sar*_*rbo 33 java ssh jsch jenkins
我正在尝试从Jenkins ssh到本地服务器,但抛出以下错误:
[SSH] Exception:Algorithm negotiation fail
com.jcraft.jsch.JSchException: Algorithm negotiation fail
at com.jcraft.jsch.Session.receive_kexinit(Session.java:520)
at com.jcraft.jsch.Session.connect(Session.java:286)
at com.jcraft.jsch.Session.connect(Session.java:150)
at org.jvnet.hudson.plugins.SSHSite.createSession(SSHSite.java:141)
at org.jvnet.hudson.plugins.SSHSite.executeCommand(SSHSite.java:151)
at org.jvnet.hudson.plugins.SSHBuildWrapper.executePreBuildScript(SSHBuildWrapper.java:75)
at org.jvnet.hudson.plugins.SSHBuildWrapper.setUp(SSHBuildWrapper.java:59)
at hudson.model.Build$BuildExecution.doRun(Build.java:154)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:533)
at hudson.model.Run.execute(Run.java:1754)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
at hudson.model.ResourceController.execute(ResourceController.java:89)
at hudson.model.Executor.run(Executor.java:240)
Finished: FAILURE
Run Code Online (Sandbox Code Playgroud)
SSH服务器上安装的Java版本:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Run Code Online (Sandbox Code Playgroud)
客户端上安装的java版本:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b18)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
Run Code Online (Sandbox Code Playgroud)
还尝试了这个解决方案: JSchException:算法协商失败 但它不起作用.从腻子一切似乎都没问题.建立连接,但是当我触发Jenkins作业时,会抛出错误.我应该尝试另一个版本的ssh服务器.现在我正在使用copssh.
Mat*_*iez 64
TL; DR编辑你的sshd_config并在KexAlgorithms中启用对diffie-hellman-group-exchange-sha1和diffie-hellman-group1-sha1的支持:
KexAlgorithms curve25519-sha256@libssh.org,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
Run Code Online (Sandbox Code Playgroud)
我怀疑在OpenSSH 6.7中发生以下更改后问题出现了:"默认的密码和MAC集已被更改以删除不安全的算法." (见changelog).这个版本于10月6日发布,并于10月21日发布到Debian测试版(参见Debian更改日志).
默认情况下,OpenSSH仅启用以下密钥交换算法:
而JSch声称支持密钥交换的这些算法(参见"特性"下):
实际上,他们无法就共同密钥交换算法达成一致.更新sshd_config(并重新启动SSH服务器)可以解决问题.显然,自0.1.50版本开始,JSch应该支持"diffie-hellman-group-exchange-sha256"方法(参见changelog).
如下所述:http://sourceforge.net/p/jsch/mailman/message/32975616/,在JSch 0.1.51中实现了diffie-hellman-group-exchange-sha256,但未启用.您可以使用如下setConfig函数启用它:
JSch jsch = new JSch();
java.util.Properties configuration = new java.util.Properties();
configuration.put("kex", "diffie-hellman-group1-sha1,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group-exchange-sha256");
configuration.put("StrictHostKeyChecking", "no");
Session session = jsch.getSession("username", "hostname", 22);
session.setPassword("password");
session.setConfig(configuration);
session.connect();
Run Code Online (Sandbox Code Playgroud)
我们的jenkins(2.21)和SSH插件(2.4)遇到了同样的问题
我们的解决方案是使用nativ shell执行.似乎jenkins插件不使用与nativ shell相同的ssh连接设置.
所以你可以像这样连接ssh(没有ssh-plugin):
ssh user@host <<'ENDSSH'
echo your remote command here
ENDSSH
Run Code Online (Sandbox Code Playgroud)
如果使用上面的代码包装远程命令,则连接正常.
有了这个解决方案,你就不再需要ssh-plugin了.
您的信息:我们在mittwald服务器上遇到了问题,因为他们升级了服务器上的openssh.
| 归档时间: |
|
| 查看次数: |
58676 次 |
| 最近记录: |