This is a step-by-step instruction to add a Linux slave node to Jenkins.
- Get a new server that runs Linux
- Set up a Jenkins user (you don’t necessarily need Jenkins itself installed, but you need a dedicated user), with a home folder and proper permissions. Ideally, the user is called “jenkins” on both machines.
- Put the master’s Jenkins SSH public key on the slave’s Jenkins user authorized_keys file (e.g.
Adding the node to Jenkins
- Log into Jenkins with an administrator account
- On the Home page, go to “Manage Jenkins”, then “Manage Nodes”
- On the left, press “New Node”
- Enter a node name, then press “Dumb Slave”, then OK
- Enter “1” as the number of executors (you probably don’t want to build two devices at the same time)
- Enter your path to your jenkins user home in “Remote root directory” (e.g.
- Make sure Usage is set to “Only build jobs with label restrictions matching this node”, and Launch method is set to “Launch slave agents on Unix machines via SSH”
- Below the Launch method drop-down, enter the slave’s IP address in “Host”
- Choose the credential of jenkins user on master, otherwise create a new one as below
- Press “Add” to create a new credential
- Select “SSH Username with private key” kind, enter the remote username (in our case, “jenkins”)
- Input the private key directly or select option “From the Jenkins master ~/.ssh”
- If your key has a passphrase, press “Advanced” and type in the passphrase
- Press Save to close the dialog, and choose your new credential in the list
- Press Save again to save your node.
Your node is now setup! If connection can be made properly, you should see the slave’s statistics appearing in the “Manage Nodes” page.
How to generate key-pare for SSH connection
Open PuTTYgen and click “Generate” button with key type “SSH-2 RSA“, download the public and private key files to local disk.
The public key must be in one line and starts with “ssh-rsa“, e.g.
The private key is stored in Jenkins system as a credential object with below,
- Kind – SSH Username with private key
- Scope – System (Jenkins and nodes only)
- Username – jenkins
- Description – <be specific>
- Private key – Enter directly or From a file or From ~/.ssh
How to set up Jenkins user
Create a new user named as “jenkins” if it’s not existed on Linux node
Use command “useradd” or “adduser” in Linux and other Unix-like operating systems, and set a non-empty password to unlock the user
Set proper permissions to jenkins user home directory and .ssh directory
How to trouble shoot when it still goes wrong
Enable the debug level log in file
Check the log from
How To Fix “Server refused our key” Error in CentOS 6
Refer to link, try below command