5

I want to connect a slave to Master-Jenkins, but when trying to connect i'm getting following Error:

[05/02/18 15:26:59] [SSH] Opening SSH connection to <IP>
Key exchange was not finished, connection is closed.
java.io.IOException: There was a problem while connecting to <IP>:22
    at com.trilead.ssh2.Connection.connect(Connection.java:818)
    at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1324)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:831)
    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:820)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Key exchange was not finished, connection is closed.
    at com.trilead.ssh2.transport.KexManager.getOrWaitForConnectionInfo(KexManager.java:93)
    at com.trilead.ssh2.transport.TransportManager.getConnectionInfo(TransportManager.java:230)
    at com.trilead.ssh2.Connection.connect(Connection.java:770)
    ... 7 more
Caused by: java.io.IOException: Cannot negotiate, proposals do not match.
    at com.trilead.ssh2.transport.KexManager.handleMessage(KexManager.java:405)
    at com.trilead.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:777)
    at com.trilead.ssh2.transport.TransportManager$1.run(TransportManager.java:489)
    ... 1 more
[05/02/18 15:26:59] Launch failed - cleaning up connection
[05/02/18 15:26:59] [SSH] Connection closed.

Configuration for Node: - Start-Method: Start Slave over SSH - Hostname: is the IP - Access Data: user i created for SSH Access - > public key is in authorized keys on Slave Node

If i am on my Master as user "jenkins" and do a ssh jenkins@<IP> i can login wihtout problems (public key is on slave).

Why it doesn't work for "UI-Jenkins".

Jenkins-Version: 1.658

Node: Ubuntu 14.04

SSH-Slave Plugin: 1.26

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Merowinger
  • 111
  • 1
  • 1
  • 6

4 Answers4

4

That "solved" the issue:

"Workaround is by commenting out MACs and KexAlgorithm line in /etc/ssh/sshd_config of Jenkins Slave and restarting the sshd (service ssh restart on Ubuntu)

UPDATE: the issue has been resolved as of 2017-04-29 "

Jenkins master fails to connect to the slave over SSH

Merowinger
  • 111
  • 1
  • 1
  • 6
  • Additionally: you may have to uncheck "Require manual verification of initial connection" in the configuration of the agent. – FCA69 Apr 21 '23 at 12:37
1

Thought I'd throw my experience in this thread: my environment had a Windows master and mixed Windows and Linux agents. One Windows agent refused to connect to master, even after Master pushed 'jenkins-agent' and the other supporting files to the agent.

This agent had 6 different versions of the JDK and JRE installed. I uninstalled all of them, reinstalled only the latest JDK we needed, and set JAVA_HOME. This fixed the connectivity issue.

Core PCN
  • 21
  • 2
0

Execute this command on destination node.

sudo -i su -c 'sed -i -e "s/MACs /MACs hmac-sha1,/g" /etc/ssh/sshd_config; service sshd restart'

OrcunK
  • 1
0

Just recently run into this issue with docker

Find the Java Path

/home/jenkins # which java
/opt/java/openjdk/bin/java

Export the Java Path. In this case I am using the docker-compose

...
  exp_agent:
    image: jenkins/ssh-agent:alpine
    restart: always
    environment:
      JENKINS_AGENT_SSH_PUBKEY: $ENV_JENKINS_AGENT_SSH_PUBKEY
      JAVA_HOME: $ENV_JAVA_HOME
    container_name: jenkins-ssh-agent
    ports:
      - 22:22
    networks:
      - jenkins
...

The master still complains about the path of Java as /opt/java/openjdk/bin/java is not among the expected paths

...
[12/04/21 11:44:07] [SSH] Checking java version of /usr/bin/java
...

Create a symbolic link between the java path and one of the expected paths in the docker container (This could be automated in a Dockerfile)

ln -s /opt/java/openjdk/bin/java /usr/bin/java
philo
  • 121
  • 1
  • 9