Jsch connection SSH problem exception:algorithm negotiation fail

Source: Internet
Author: User
Tags hmac md5 sha1 ssh ssh server

Using Jenkins to configure the remote SSH server, an unreachable problem occurs, and after viewing the log, locate

[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

Reason Analysis:

Unlike the exchange algorithms supported by OpenSSH and Jsch, one side is required to open the Exchange algorithm supported by the other.

OpenSSH enables only the following key exchange algorithms by default:
-curve25519-sha256@libssh.org
-ecdh-sha2-nistp256
-ecdh-sha2-nistp384
-ecdh-sha2-nistp521
-diffie-hellman-group-exchange-sha256
-DIFFIE-HELLMAN-GROUP14-SHA1

Where as Jsch claims to support this algorithms for key exchange:
-DIFFIE-HELLMAN-GROUP-EXCHANGE-SHA1
-DIFFIE-HELLMAN-GROUP1-SHA1

Solution:

In the SSH configuration file
/etc/ssh/sshd_config

Add the following two lines to allow SSH to support the corresponding algorithm and Macs


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

MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com, UMAC-128-ETM@OPENSSH.COM,HMAC-SHA2-512,HMAC-SHA2-256,HMAC-RIPEMD160,UMAC-128@OPENSSH.COM,HMAC-MD5,HMAC-SHA1, hmac-sha1-96,hmac-md5-96

Reboot SSH After completion to resolve the problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.