How to connect a build node to a Jenkins master?
Connecting a node to Jenkins through a terminal only is a two step process.

First, you should ssh into into your node machines and set them up with the following steps:


Make a jenkins user shell:  sudo adduser jenkins --shell /bin/bash
Create the directory after switching to the jenkins user:  mkdir /home/jenkins/jenkins_slave
Create your SSH credentials to be used in the following bash script.


Then, once your nodes are set up, you will need to connect to your jenkins machine and run bash script such as this one to connect your nodes to your master:

  

#!/bin/bash

JENKINS_URL=$1
NODE_NAME=$2
NODE_SLAVE_HOME='/home/build/slave'
EXECUTORS=1
SSH_PORT=22
CRED_ID=$3
LABELS=build
USERID=${USER}

cat &lt;&lt;EOF | java -jar ~/bin/jenkins-cli.jar -s $1 create-node $2
&lt;slave&gt;
  &lt;name&gt;${NODE_NAME}&lt;/name&gt;
  &lt;description&gt;&lt;/description&gt;
  &lt;remoteFS&gt;${NODE_SLAVE_HOME}&lt;/remoteFS&gt;
  &lt;numExecutors&gt;${EXECUTORS}&lt;/numExecutors&gt;
  &lt;mode&gt;NORMAL&lt;/mode&gt;
  &lt;retentionStrategy class="hudson.slaves.RetentionStrategy$Always"/&gt;
  &lt;launcher class="hudson.plugins.sshslaves.SSHLauncher" plugin="ssh-slaves@1.5"&gt;
    &lt;host&gt;${NODE_NAME}&lt;/host&gt;
    &lt;port&gt;${SSH_PORT}&lt;/port&gt;
    &lt;credentialsId&gt;${CRED_ID}&lt;/credentialsId&gt;
  &lt;/launcher&gt;
  &lt;label&gt;${LABELS}&lt;/label&gt;
  &lt;nodeProperties/&gt;
  &lt;userId&gt;${USERID}&lt;/userId&gt;
&lt;/slave&gt;
EOF