Jenkins Tutorial: How to add Linux Node (Slave) to Jenkins?

3 Mins read

We have performed the installation of Jenkins on Ubuntu in the previous guide. Now, it is time to add Jenkins Linux Node (Slave) to the Jenkins Master. For more information on Jenkins, you can follow the following guide: What is Jenkins?


  • Ubuntu Server 18.04 (This guide will use this OS)
  • A user account with SUDO privileges.
  • Java 8 (Jenkins supports this version)

Steps for Jenkins Linux Node (Slave) Installation

  1. Install Java 8 on Node
  2. Create a user and configure permissions on Node
  3. Configure SSH Connection between Master and Node
  4. Add and configure the Node on Jenkins Web UI
  5. Finish the installation of Node

1) Install Java 8 on Node

First of all, it would be better to check if Java is installed on the Node. If it is already installed, you can skip this step.

java -version
check if java installed

It is currently not installed on the server. So, let’s install the Java JDK 8 on Linux Node (Slave).

sudo apt-get install openjdk-8-jdk
java install on node

Now, we are going to check if the Java is successfully installed.

java -version
check java version

Conguratulations! Java JDK 8 is installed successfully on Linux Node!

2) Create a user and configure permissions on Node

On the Linux Node, we need to create a jenkins user that will be in communication with Jenkins Master.

sudo useradd jenkins -U -m -s /bin/bash
sudo passwd jenkins
node create user and password

We have created a new user and set a password. Next, we are going to add this user to the sudo group which gives sudo privileges to the user.

sudo usermod -aG sudo jenkins
add user to sudo group

3) Configure SSH Connection between Master and Node

We have created a user that Jenkins Master will use it to connect to the Node. Next, we are going to configure SSH to establish connections between Jenkins Master and the Jenkins Node.

On the Jenkins Master server:

su - jenkins
generate ssh key

This command will connect to the jenkins user and create the SSH public key and private key on the Master. It will ask you to answer some questions but you may leave them empty as default by pressing enter. We are going to copy the private key content to write it on the configuration of Jenkins Web UI at the next step.

cat /var/lib/jenkins/.ssh/id_rsa
cat ssh private key

Next, on the master, run the following command for adding public keys to the nodes. The target IP address or Hostname will be Linux Node. It will ask you to enter the password for Node.

ssh-copy-id jenkins@
ssh copy id to jenkins node

Now, we can try the SSH connection between Master and Slave (Node).

ssh 'jenkins@'
ssh connections check

Conguratulations! Jenkins Master can create a connection to the Jenkins Node (Slave) successfully!

4) Add and configure the Node on Jenkins Web UI

Next, we are going to add our new Node to the Jenkins on the Web UI.

Go to the Jenkins Web UI and login to the system. Then, click on the Manage Jenkins link on the left menu.

manage jenkins menu

Next, click on the Manage Nodes and Clouds button.

manage nodes and clouds

On the left side, click on the New Node menu.

new node menu

On this page, specify a name for your Jenkins Node and select Permanent Agent option. Then, click on the OK button.

node initial info

On the next page, fill the required fields as shown below.

jenkins node page
  • # of executors: 1 (This field specifies how many jobs can be executed at the same time on the node.)
  • Remote root directory: /home/jenkins
  • Labels: node1 (You can specify a label for nodes to categorize them.)
  • Launch method: Launch agents via SSH (This option must be selected as this guide use this connection method. If you are using different connection methods, you may select the other options.)
  • Host: (IP address or Hostname of the Node)
  • Credentials: jenkins (This credential will be set up at the next step.)

Click on the Add button near to Credentials sections.

jenkins node add credentials

Click on the Jenkins from the list.

jenkins add user credentials

On this page, select SSH Username with private key option from Kind. Then, fill the Username field with jenkins. Next, select the Enter directly option. Then, paste the private key content to the text area which we have got it from previous step. Click on the Add button.

After adding credentials, click on the Save button on the main page.

jenkins node list

After that, it will redirect you to Node List page. So, the node we just added has been added to the list.

Next, click on the Node Name and then go to the Log menu on the left side.

jenkins log menu

Conguratulations! You have added a new node to the Jenkins successfully!

jenkins agent successful log
jenkins linux node
Recep Duman
26 posts

About author
I am a fan of programming, innovation, and web development. I’m also interested in technology and entrepreneurship.
Related posts

Jenkins Tutorial: How to install Jenkins on Ubuntu?

2 Mins read
Before moving on to the installation of Jenkins, let’s talk about it. Jenkins is a very popular Continuous integration tool. Jenkins is…

What is Jenkins?

2 Mins read
Jenkins is the leading open-source Continuous Integration tool. It provides over 1000 plugins to support the creation and testing of almost any…
Subscribe to Newsletter

To get the latest news, subscribe our channel.

Leave a Reply

Your email address will not be published. Required fields are marked *


What is Jenkins?