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