I have installed Jenkins on a Centos VM as I am looking at replacing Bamboo, I have it all up and running by following the install instructions. That went fine, I then wanted to spin up a Slave, I created a second VM, created a user on it, created a SSH key for that user. I then created a Slave node in Jenkins but when I created the account in Jenkins for the Slave machine and supplied the SSH Private key I got and error. Which is right as I did not put the Master SSH pub key on the Slave in the ~/.ssh/authorized_keys.

It looks like the Centos Yum install does not create ssh keys for the user running Jenkins, I did my Google fu and from what I read I need this to do what I want to do. I did try SU as the on the machine but with no luck. I would like to know how I need to do this, as I would sooner use SSH keys.

In saying all of this I have got a slave going by using the SSH option using a password, it works but it's not the way I want to do this.

Any help would be super!


I just had the same problem. What I did was:

  1. On the master change to root user: su root
  2. Execute: passwd jenkins
  3. Specify a password for the jenkins user
  4. Change to the jenkins user (and supply password from step 3): su jenkins
  5. Run ssh-keygen

That solved the problem for me. I could not do sudo passwd jenkins, I had to change to the root user. You might also want to add the remote server to the know_hosts file.

  • Hi, thanks for this, I have now got it working using SSH keys :) The only other part I needed to do is update the passwd file to set BASH for login. Once I did that I was fine. – djo Jul 7 '13 at 23:03

A more suitable way to achieve the same thing would be to run:

# sudo -u jenkins ssh-keygen

That will generate the key for you here:

  • Works like a charm! – Mateusz Chrzaszcz Oct 26 '16 at 15:07
  • 2
    This is should be the accepted answer – Arun Killu Mar 27 '17 at 14:55
  • In my specific use case (gerrit) I had to ssh into the server to get the known_hosts entry added. – memoselyk Aug 24 '17 at 22:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.