Hello Team,
Unable to run jenkins build inside a docker agent agent using SSH connection method.Getting below error:
[12/14/23 16:34:07] [SSH] Opening SSH connection to 192.168.56.110:32793.
Key exchange was not finished, connection is closed.
SSH Connection failed with IOException: “Key exchange was not finished, connection is closed.”, retrying in 15 seconds. There are 10 more retries left.
Key exchange was not finished, connection is closed.
SSH Connection failed with IOException: “Key exchange was not finished, connection is closed.”, retrying in 15 seconds. There are 9 more retries left.
Key exchange was not finished, connection is closed.
Below is the Dockerfile used for creating the docker image:
FROM centos:7
# Install SSH server, Java, and other required packages
RUN yum -y install openssh-server java-11-openjdk-devel curl
# Create Jenkins user and set up directories
RUN useradd -m -s /bin/bash jenkins && *
** mkdir -p /home/jenkins/.ssh && *
** chown -R jenkins:jenkins /home/jenkins && **
** chmod 700 /home/jenkins/.ssh**
# Generate SSH keys for the Jenkins user
RUN ssh-keygen -t rsa -f /home/jenkins/.ssh/id_rsa
# Generate SSH host keys
RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ‘’ && *
** ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ‘’ && *
** ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N ‘’**
# Copy the public key to the authorized_keys file for the Jenkins user
RUN cat /home/jenkins/.ssh/id_rsa.pub >> /home/jenkins/.ssh/authorized_keys && *
** chmod 600 /home/jenkins/.ssh/authorized_keys*
# SSH configuration for key-based authentication
RUN sed -i ‘s/#PubkeyAuthentication yes/PubkeyAuthentication yes/’ /etc/ssh/sshd_config && *
** sed -i ‘s/#PasswordAuthentication yes/PasswordAuthentication no/’ /etc/ssh/sshd_config*
# Expose SSH port
EXPOSE 22
CMD [“/usr/sbin/sshd”, “-D”]
Also, I am able to create the container using this dockerfile.
Can someone please help in checking this issue?