Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setting up a Jenkins slave on Linux
# This is how you add a Jenkins slave
# On master:
sudo -u jenkins -H ssh-keygen
# On slave
adduser --system --group --home=/var/lib/jenkins-slave --no-create-home --disabled-password --quiet --shell /bin/bash jenkins-slave
install -d -o jenkins-slave -g jenkins-slave /var/lib/jenkins-slave
install -d -m 700 -o jenkins-slave -g jenkins-slave /var/lib/jenkins-slave/.ssh
vi /var/lib/jenkins-slave/.ssh/authorized_keys
copy jenkinsmasterhost:/var/lib/jenkins/ssh/id_rsa.pub
# On master
sudo -u jenkins -H ssh jenkins-slave@muskatas
# remember the host key
# Now you can add an SSH slave through the Jenkins web UI, it'll download all the Java .jars automatically
# (you may need to sudo apt-get install openjdk or something on the slave machine)
# To allow the slave to get access to git repos on mygitserver, run this on the slave machine:
sudo -u jenkins-slave -H ssh-keygen
# On mygitserver
adduser --system --group --home=/var/lib/jenkins-slave --no-create-home --disabled-password --quiet --shell /usr/bin/git-shell jenkins-slave
install -d -o jenkins-slave -g jenkins-slave /var/lib/jenkins-slave
install -d -m 700 -o jenkins-slave -g jenkins-slave /var/lib/jenkins-slave/.ssh
vi /var/lib/jenkins-slave/.ssh/authorized_keys
copy /var/lib/jenkins-slave/ssh/id_rsa.pub from the slave machine
# On slave
sudo -u jenkins-slave -H ssh mygitserver
# remember the host key
sudo -u jenkins-slave -H git config --global user.name 'Jenkins'
sudo -u jenkins-slave -H git config --global user.email 'root@example.com'
@drauschenbach

This comment has been minimized.

Copy link

drauschenbach commented May 15, 2017

We're not self-hosting Git so you can remove those two big sections. The Jenkins master should push the necessary keys along with the job.

@inl-pd-autotest

This comment has been minimized.

Copy link

inl-pd-autotest commented Dec 22, 2017

adduser for me has no --group, but it has --groups and of course it requires at least 1 group to be listed, which one does jenkins slave need?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.