Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (12.7k points)

I am successfully able to connect to remote machine using SSH but when I am launching the agent from Jenkins it throws the following error:

ERROR: Server rejected the 1 private key(s) for user1 (credentialId:xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/method:publickey)

[01/19/17 05:35:15] [SSH] Authentication failed.

hudson.AbortException: Authentication failed.

    at hudson.plugins.sshslaves.SSHLauncher.openConnection(

    at hudson.plugins.sshslaves.SSHLauncher$

    at hudson.plugins.sshslaves.SSHLauncher$


    at java.util.concurrent.ThreadPoolExecutor.runWorker(

    at java.util.concurrent.ThreadPoolExecutor$


[01/19/17 05:35:15] Launch failed - cleaning up connection

[01/19/17 05:35:15] [SSH] Connection closed.

I can establish SSH connection from master machine to the node machine using user1, however when I am trying to launch the agent using user1 from jenkins it is rejecting the private key. Is there any solution to overcome this issue?

1 Answer

0 votes
by (29.5k points)
Please try the following :

Switch to the “root” user.
-sudo su
-Add a jenkins user with the home “/var/lib/jenkins”. {Note : I am keeping my home directory in /var/lib/jenkins} :
useradd -d /var/lib/jenkins jenkins
-From the Jenkins Master

-Copy the key from the Jenkins user on the master.

-cat /var/lib/jenkins/.ssh/
From the target slave node's console

-Create an authorized_keys file for the Jenkins user.

mkdir /var/lib/jenkins/.ssh
vi /var/lib/jenkins/.ssh/authorized_keys
Paste the key from the Jenkins master into the file vim. Save with “:wq!”

Browse Categories