The Nautilus DevOps team has installed and configured new Jenkins server in Stratos DC which they will use for CI/CD and for some automation tasks. There is a requirement to add all app servers as slave nodes in Jenkins so that they can perform tasks on these servers using Jenkins. Find below more details and accomplish the task accordingly.
Click on the Jenkins button on the top bar to access the Jenkins UI. Login using username admin and password Adm!n321.
Add all app servers as SSH build agent/slave nodes in Jenkins. Slave node name for
app server 1,app server 2andapp server 3must beApp_server_1,App_server_2,App_server_3respectively.Add labels as below:
App_server_1 : stapp01
App_server_2 : stapp02
App_server_3 : stapp03
Remote root directory for
App_server_1must be/home/tony/jenkins, forApp_server_2must be/home/steve/jenkinsand forApp_server_3must be/home/banner/jenkins.Make sure slave nodes are online and working properly.
Note:
- You might need to install some plugins and restart Jenkins service. So, we recommend clicking on
Restart Jenkins when installation is complete and no jobs are runningon plugin installation/update page i.eupdate centre. Also, Jenkins UI sometimes gets stuck when Jenkins service restarts in the back end. In this case, please make sure to refresh the UI page. - For these kind of scenarios requiring changes to be done in a web UI, please take screenshots so that you can share it with us for review in case your task is marked incomplete. You may also consider using a screen recording software such as loom.com to record and share your work.
Understanding Jenkins Master-Agent Architecture
Jenkins uses a master-agent architecture:
| Component | Role |
|---|---|
| Master (Controller) | Schedules jobs, manages configuration, serves the UI |
| Agent (Slave/Node) | Executes build tasks assigned by the master |
Why Use Slave Nodes?
- Distributed Builds: Run multiple jobs in parallel
- Server-Specific Tasks: Run jobs on specific servers
- Load Distribution: Reduce load on the master
- Environment Isolation: Different environments for different builds
- Scalability: Add more agents as needed
Task Requirements
| Server | Node Name | Label | Remote Root Directory |
|---|---|---|---|
| App Server 1 | App_server_1 | stapp01 | /home/tony/jenkins |
| App Server 2 | App_server_2 | stapp02 | /home/steve/jenkins |
| App Server 3 | App_server_3 | stapp03 | /home/banner/jenkins |
Step-by-Step Implementation
Step 1: Access Jenkins UI
- Click the Jenkins button on the top bar
- Login with:
-
Username:
admin -
Password:
Adm!n321
-
Username:
Step 2: Install SSH Build Agents Plugin
- Navigate to Manage Jenkins → Plugins
- Click Available plugins
- Search for SSH Build Agents
- Install the plugin and restart Jenkins
Note: Select Restart Jenkins when installation is complete and no jobs are running.
Step 3: Generate SSH Keys on Jenkins Server
The Jenkins job runs as the jenkins user, so SSH keys must be generated for this user.
# SSH to Jenkins server
ssh jenkins@jenkins
# Password: j@rv!s
# Generate SSH key
ssh-keygen -t rsa -b 4096 -N "" -f ~/.ssh/id_rsa
# View the private key (needed for Jenkins credentials)
cat ~/.ssh/id_rsa
Output:
Generating public/private rsa key pair.
Your identification has been saved in /var/lib/jenkins/.ssh/id_rsa
Your public key has been saved in /var/lib/jenkins/.ssh/id_rsa.pub
Step 4: Copy SSH Keys to All App Servers
# Copy public key to App Server 1
ssh-copy-id -o StrictHostKeyChecking=no tony@stapp01
# Password: Ir0nM@n
# Copy public key to App Server 2
ssh-copy-id -o StrictHostKeyChecking=no steve@stapp02
# Password: Am3ric@
# Copy public key to App Server 3
ssh-copy-id -o StrictHostKeyChecking=no banner@stapp03
# Password: BigGr33n
# Verify passwordless access
ssh -o StrictHostKeyChecking=no tony@stapp01 hostname
ssh -o StrictHostKeyChecking=no steve@stapp02 hostname
ssh -o StrictHostKeyChecking=no banner@stapp03 hostname
Output:
stapp01
stapp02
stapp03
Step 5: Install Java 21 on All App Servers
Jenkins agents require Java 17 or higher. Java 11 will cause an UnsupportedClassVersionError.
# Install Java 21 on all servers
ssh tony@stapp01 "sudo yum install -y java-21-openjdk"
ssh steve@stapp02 "sudo yum install -y java-21-openjdk"
ssh banner@stapp03 "sudo yum install -y java-21-openjdk"
Step 6: Register and Set Java 21 as Default
After installing Java 21, you need to register it as an alternative and set it as default.
# Register Java 21 as an alternative
ssh tony@stapp01 "echo 'Ir0nM@n' | sudo -S alternatives --install /usr/bin/java java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java 2000"
ssh steve@stapp02 "echo 'Am3ric@' | sudo -S alternatives --install /usr/bin/java java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java 2000"
ssh banner@stapp03 "echo 'BigGr33n' | sudo -S alternatives --install /usr/bin/java java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java 2000"
# Set Java 21 as default
ssh tony@stapp01 "echo 'Ir0nM@n' | sudo -S alternatives --set java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java"
ssh steve@stapp02 "echo 'Am3ric@' | sudo -S alternatives --set java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java"
ssh banner@stapp03 "echo 'BigGr33n' | sudo -S alternatives --set java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java"
Verify:
ssh tony@stapp01 "java -version"
ssh steve@stapp02 "java -version"
ssh banner@stapp03 "java -version"
Output:
openjdk version "21.0.12.1" 2026-08-18 LTS
Step 7: Create Remote Root Directories
ssh -o StrictHostKeyChecking=no tony@stapp01 "mkdir -p /home/tony/jenkins"
ssh -o StrictHostKeyChecking=no steve@stapp02 "mkdir -p /home/steve/jenkins"
ssh -o StrictHostKeyChecking=no banner@stapp03 "mkdir -p /home/banner/jenkins"
Step 8: Get IP Addresses for Hostname Resolution
ssh tony@stapp01 "hostname -I"
ssh steve@stapp02 "hostname -I"
ssh banner@stapp03 "hostname -I"
Output:
10.244.81.4
10.244.189.193
10.244.195.103
Step 9: Add SSH Credentials in Jenkins
- Go to Manage Jenkins → Credentials → System → Global credentials
- Click Add Credentials for each server:
App Server 1 Credentials:
- Kind: SSH Username with private key
- Scope: Global
-
ID:
stapp01-credentials -
Username:
tony -
Private Key: Enter directly (paste the private key from
~/.ssh/id_rsa) - Click OK
App Server 2 Credentials:
- Kind: SSH Username with private key
-
ID:
stapp02-credentials -
Username:
steve - Private Key: Enter directly
- Click OK
App Server 3 Credentials:
- Kind: SSH Username with private key
-
ID:
stapp03-credentials -
Username:
banner - Private Key: Enter directly
- Click OK
Step 10: Add Slave Nodes in Jenkins
Add App_server_1 Node:
- Manage Jenkins → Nodes → New Node
- Enter name:
App_server_1 - Select Permanent Agent → OK
- Configure:
-
Name:
App_server_1 -
Remote root directory:
/home/tony/jenkins -
Labels:
stapp01 - Usage: Use this node as much as possible
- Launch method: Launch agents via SSH
-
Host:
stapp01.stratos.xfusioncorp.com -
Credentials:
stapp01-credentials - Host Key Verification Strategy: Non-verifying Verification Strategy
-
Name:
- Click Advanced and set:
-
JavaPath:
/usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java
-
JavaPath:
- Click Save
Add App_server_2 Node:
- Manage Jenkins → Nodes → New Node
- Enter name:
App_server_2 - Configure:
-
Name:
App_server_2 -
Remote root directory:
/home/steve/jenkins -
Labels:
stapp02 -
Host:
stapp02.stratos.xfusioncorp.com -
Credentials:
stapp02-credentials -
JavaPath:
/usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java
-
Name:
- Click Save
Add App_server_3 Node:
- Manage Jenkins → Nodes → New Node
- Enter name:
App_server_3 - Configure:
-
Name:
App_server_3 -
Remote root directory:
/home/banner/jenkins -
Labels:
stapp03 -
Host:
10.244.195.103(use IP address since hostname doesn't resolve) -
Credentials:
stapp03-credentials -
JavaPath:
/usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java
-
Name:
- Click Save
Step 11: Verify All Nodes Are Online
Go to Manage Jenkins → Nodes. All three nodes should show Online status with a green checkmark.
Troubleshooting Common Issues
Issue 1: UnsupportedClassVersionError
Error:
java.lang.UnsupportedClassVersionError: hudson/remoting/Launcher has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
Cause: Jenkins agent requires Java 17+ but the server has Java 11.
Solution: Install Java 21 and set it as default.
sudo yum install -y java-21-openjdk
sudo alternatives --install /usr/bin/java java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java 2000
sudo alternatives --set java /usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.1.el9.x86_64/bin/java
Issue 2: "has not been configured as an alternative"
Error:
/usr/lib/jvm/java-21-openjdk-21.0.12.1.1-2.el9.x86_64/bin/java has not been configured as an alternative for java
Cause: Java 21 was not registered as an alternative before using --set.
Solution: Use --install first, then --set.
Issue 3: Wrong Java Path
Error: Path uses -2.el9.x86_64 but the actual path is -2.1.el9.x86_64.
Solution: Verify the exact path:
ls /usr/lib/jvm/
Issue 4: Name or Service Not Known
Error:
stapp03.stratos.xfusioncorp.com: Name or service not known
Cause: The hostname cannot be resolved from the Jenkins server.
Solution: Use the IP address directly in the node configuration.
Issue 5: Jenkins User Cannot Use Sudo
Error:
jenkins is not in the sudoers file.
Cause: The jenkins user doesn't have sudo privileges.
Solution: Use IP addresses in node configuration instead of editing /etc/hosts.
Final Configuration Summary
| Node Name | Label | Remote Root Directory | Host | JavaPath | Status |
|---|---|---|---|---|---|
| App_server_1 | stapp01 | /home/tony/jenkins | stapp01.stratos.xfusioncorp.com | Java 21 | Online |
| App_server_2 | stapp02 | /home/steve/jenkins | stapp02.stratos.xfusioncorp.com | Java 21 | Online |
| App_server_3 | stapp03 | /home/banner/jenkins | 10.244.195.103 | Java 21 | Online |
Key Learnings
Java Version Compatibility: Jenkins agents require Java 17 or higher. Java 21 is recommended.
Alternatives Management: Use
alternatives --installto register a new Java version, thenalternatives --setto make it default.JavaPath in Node Configuration: For non-interactive SSH sessions, always specify the full Java binary path in the agent configuration.
Hostname Resolution: If a hostname cannot be resolved, use the IP address directly in the node configuration.
Jenkins User Permissions: The
jenkinsuser may not have sudo access, so plan accordingly.SSH Key Setup: Generate SSH keys for the
jenkinsuser (not root) and copy them to all target servers.
Benefits of Distributed Builds
With slave nodes configured, you can now:
- Run jobs in parallel across multiple servers
-
Target specific servers using labels (
stapp01,stapp02,stapp03) - Reduce load on the Jenkins master
- Scale horizontally by adding more agents
- Isolate environments for different build types
Example: Using Node Labels in a Job
node('stapp01') {
stage('Deploy') {
sh 'echo "Deploying to App Server 1"'
}
}
Summary
In this challenge, we successfully:
- Generated SSH keys on the Jenkins server
- Copied SSH keys to all app servers
- Installed Java 21 on all app servers
- Registered and set Java 21 as the default version
- Created remote root directories on all app servers
- Added SSH credentials in Jenkins
- Added all three app servers as Jenkins slave nodes
- Configured labels and JavaPath for each node
- Verified all nodes are online and working
This setup enables Jenkins to distribute build tasks across all app servers, improving performance and allowing server-specific automation tasks. The slave nodes are now ready to execute jobs assigned to them.

Top comments (0)