Why Jenkins says "Server rejected the 1 private key(s)" while launching the agent?
I solve this issue following below steps:
From the target slave node's console
- 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 /var/lib/jenkins/.ssh/id_rsa.pub
key from the Jenkins user on the master
From the target slave node's console
- Create an authorized_keys file for the Jenkins user
mkdir /var/lib/jenkins/.ssh
touch /var/lib/jenkins/.ssh/authorized_keys
Paste the key from the Jenkins master into the file vim. Save with
:wq!
Make sure the files have correct owner and permission.
chown -R jenkins /var/lib/jenkins/.ssh
chmod 600 /var/lib/jenkins/.ssh/authorized_keys
chmod 700 /var/lib/jenkins/.ssh