Hello everyone,
I have a problem during creating a new node for the host on another docker which should be connected via ssh.
- Jenkins is hosted by docker jenkins/jenkins:latest
- Another docker container is centos7, (I named remote_host)
-
So, I created ssh keys for both containers (Jenkins and remote_host) with:
ssh-keygen -t rsa (without password, just enter) -
The next step it was to make sure that I can connect from Jenkins container to remote_host without password.
Inside the Jenkins container.
ssh-copy-id remote_user@remote_host
After entering a password, I tried to connect:
ssh remote_user@remote_host (I successes to connect without a password)
-
On the Jenkins web platform Dashboard/Manage Jenkins/Credentials created user:
Username: remote_user
I enter the private key (id_rsa) from remote_host container -
On the Dashboard/Manage Jenkins/ System I tried to check the connection on section SSH remote hosts
Hostname: remote_host
Port: remote_host
Enter public key
When I check, the result is: Can’t connect to server -
Creating node
Remote root directory: /home/remote_user/
Launch method: Launch agent via SSH
Host: remote_host
Credentials: I choose remote_user (wich early created)
Host Key Verification Strategy: Known host verification strategy
After that, the agent can’t to be launched, result is:
SSHLauncher{host='remote_host', port=22, credentialsId='b03f16ca-d9a4-441d-9e95-9d34a164afee', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[05/04/23 08:25:27] [SSH] Opening SSH connection to remote_host:22.
Searching for remote_host in /var/jenkins_home/.ssh/known_hosts Searching for remote_host:22 in /var/jenkins_home/.ssh/known_hosts
[05/04/23 08:25:37] [SSH] SSH host key matches key in Known Hosts file.
Connection will be allowed. ERROR: Server rejected the 1 private key(s) for remote_user (credentialId:b03f16ca-d9a4-441d-9e95-9d34a164afee/method:publickey)
[05/04/23 08:25:37] [SSH] Authentication failed. Authentication failed.
[05/04/23 08:25:37] Launch failed - cleaning up connection [05/04/23 08:25:37] [SSH] Connection closed.