Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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(SSHLauncher.java:1219)

    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:714)

    at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:709)

    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:745)

[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 id_rsa.pub key from the Jenkins user on the master.

-cat /var/lib/jenkins/.ssh/id_rsa.pub
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

...