Jenkins Node Addition
Jenkins Node Addition and Configuration Guide
[edit]This guide describes how to add and configure a new Jenkins node, install Java 11 on it, configure SSH keys, and connect it successfully to the Jenkins master.
1. Install Java 11 on the New Node
[edit]On the new Jenkins node server, install Java 11 (required for Jenkins agents to run).
Example (Debian/Ubuntu):
apt update apt install openjdk-11-jdk -y
Verify installation:
java -version
2. Configure SSH Keys for Jenkins Connection
[edit]Jenkins communicates with the node over SSH. We use the Jenkins master’s SSH key to connect to the node.
Step 2.1: Locate the Jenkins Master SSH Key
[edit]On the Jenkins master server, the SSH key pair for Jenkins is typically stored in:
/var/lib/jenkins/.ssh/id_rsa (private key) /var/lib/jenkins/.ssh/id_rsa.pub (public key)
Step 2.2: Add Jenkins Master Public Key to Node
[edit]On the node server, add the Jenkins master’s public key to:
/var/lib/jenkins/.ssh/authorized_keys
Ensure correct permissions:
chmod 700 /var/lib/jenkins/.ssh chmod 600 /var/lib/jenkins/.ssh/authorized_keys chown -R jenkins:jenkins /var/lib/jenkins/.ssh
3. Add Jenkins Node in Jenkins UI
[edit]1. Open Jenkins master web UI. 2. Go to **Manage Jenkins → Nodes → New Node**. 3. Enter the node name (e.g., ci-node). 4. Select "Permanent Agent". 5. Configure:
- Remote root directory: `/var/lib/jenkins` - Number of executors: `2` - Labels: `ci-node` - Launch method: "Launch agents via SSH"
4. Configure Node SSH Credentials
[edit]1. In Jenkins, go to **Manage Jenkins → Credentials → (Global)**. 2. Add new credentials:
- Kind: SSH Username with private key
- Username: jenkins
- Private key: Enter directly → paste contents of:
/var/lib/jenkins/.ssh/id_rsa (from Jenkins master)
3. Save credentials.
5. Link Node with Credentials
[edit]In the node configuration page: 1. Set the host to the node's IP address. 2. Select the SSH credentials saved earlier. 3. Save the node configuration.
6. Update /etc/hosts (If Required)
[edit]If the node or deployment server requires name resolution, update the `/etc/hosts` file on both servers to map hostnames to IPs.
Example:
192.168.1.100 ci-node
7. Permissions on Node
[edit]Ensure that the Jenkins user on the node has: - Access to `/var/lib/jenkins` - Proper ownership and permissions for SSH files - Ability to run Java 11
8. Verify Connection
[edit]After saving the configuration, Jenkins will attempt to connect to the node: - Logs will display Java startup commands - If successful, status will show "Agent connected"
Final Result
[edit]Once connected, the node will be available for Jenkins builds and deployments. You can now assign jobs to run on this node by using the label: ci-node