2

I saw an answer to the same issue in Algorithm negotiation fail SSH in Jenkins

I am facing the same problem, but updating ss_config did not help and I still get the same error. I also have another problem, which maybe related to this. In Jenkins general configuration I added my build slave as a remote host and gave it hostname, port, username, and keyfile path, but it still says "Can't connect to server". I wonder why, because if I login to Jenkins machine I can easily connect to my remote host in the command line using the same keyfile.

Update:

This is the line I added to ssh_config:

KexAlgorithms diffie-hellman-group1-sha1,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1

This is the console output in Jenkins:

[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.SSHBuilder.perform(SSHBuilder.java:60)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.Build$BuildExecution.build(Build.java:205)
    at hudson.model.Build$BuildExecution.doRun(Build.java:162)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:537)
    at hudson.model.Run.execute(Run.java:1741)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:381)
Build step 'Execute shell script on remote host using ssh' marked build as failure
[SSH] executing post build script:
Community
  • 1
  • 1
Ehsan Enayati
  • 299
  • 2
  • 16
  • show us verbose log at least from client, otherwise we can only guess what is the problem. Also how you changed ssh_config or sshd_config, would be helpful. – Jakuje Sep 17 '15 at 10:31
  • I updated my question, something that I do not understand is that if there is a problem with negotiating the keys how can I connect via ssh in command line from Jenkins to the remote host. – Ehsan Enayati Sep 17 '15 at 10:48
  • It is `jsch`, not `openssh` and the log is not much verbose about the reason of failure. There are also other algorithms that you can fail to negotiate -- Ciphers, MACs. – Jakuje Sep 17 '15 at 11:45

1 Answers1

5

I figured it out, I am using Ubuntu 15.04 as remote host which uses ssh version 6.7 and this version disabled most of the encryption algorithm by default. And I needed to add this line:

KexAlgorithms diffie-hellman-group1-sha1,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1

NOT to the ssh_config, BUT to sshd_config.

Ehsan Enayati
  • 299
  • 2
  • 16