Jenkins + SSH Keys = Automated Server Maintenance

Connect Jenkins to Deployment Environment Servers with SSH Keys

The following are essential steps in connecting jenkins to a series of deployment servers, so Jenkins can automate some server maintenance tasks through Jenkins jobs.

# following example assumes user 'devops' is running applications on 
# various deployment machine environments, and wants to give the jenkins 
# user SSH access to each machine in the environment

# log in to the machine running jenkins and become root
devops@jenkins ~$ sudo su

# as root user, become jenkins user
root@jenkins /home/devops# su -s /bin/bash jenkins

# use 'ssh-keygen' and follow the prompts to set up a default rsa key on 
# the jenkins machine
jenkins@jenkins:~$ ssh-keygen

# use ssh-copy-d to copy public keys from jenkins to various environment machines:
ssh-copy-id -i ~/.ssh/id_rsa.pub devops@dev.yourfqdn.server
ssh-copy-id -i ~/.ssh/id_rsa.pub devops@qa.yourfqdn.server
ssh-copy-id -i ~/.ssh/id_rsa.pub devops@stage.yourfqdn.server

# thats it, test the ssh connection from jenkins to each environment's machine:

jenkins@jenkins:~$ ssh devops@dev.yourfqdn.server
# and so on...

This set up doesn't require any further credentials to be set up in Jenkins.

Blown Away

I am blown away by this product.

Shut up and take my money.