Creating SSH key on Jenkins Master – Centos Yum Install

build-servercentos6Jenkinsssh-keys

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!

Best Answer

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.

Related Topic