Hey Devs π,
Ever wished you could install software packages on your remote servers without having to SSH into them manually every time?
Well, if you're using Jenkins β good news! You can automate that entire process with just a few clicks (and a little Bash π‘).
In this post, Iβll walk you through how I set up a Jenkins Freestyle Job to install Linux packages on a remote storage server using a parameterized build and passwordless SSH.
Letβs dive in. π§
π§© The Scenario
At xFusionCorp, the DevOps team wanted a way to:
Trigger package installations remotely
Pass the package name as a parameter
Avoid SSHing into the storage server every time
Keep it all manageable via Jenkins
So, we built a Jenkins job that:
β
Accepts a package name
β
SSHes into the remote storage server
β
Runs the install command (via yum or apt)
β
Logs the result in Jenkins
π οΈ Step-by-Step: Jenkins Freestyle Job Setup
1οΈβ£ Create a Freestyle Job
Navigate to Jenkins Dashboard β New Item
Name it install-packages
Choose Freestyle project
Click OK
2οΈβ£ Add a String Parameter
Enable This project is parameterized
Add a String Parameter
Name: PACKAGE
Description: The name of the Linux package to install (e.g., httpd, git)
3οΈβ£ Add a Shell Build Step
Hereβs the magic script π
#!/bin/bash
if [ -z "$PACKAGE" ]; then
echo "No package specified. Exiting..."
exit 1
fi
# Replace with your actual server and user
STORAGE_SERVER=192.168.1.10
REMOTE_USER=jenkins
echo "Installing $PACKAGE on $STORAGE_SERVER..."
ssh -o StrictHostKeyChecking=no $REMOTE_USER@$STORAGE_SERVER "sudo yum install -y $PACKAGE"
π Setup SSH and Sudo Access
To make the above work without interruptions:
β
1. Passwordless SSH
From your Jenkins server (as the jenkins user):
ssh-keygen -t rsa -b 4096 -N ""
ssh-copy-id jenkins@<storage-server-ip>
β
2. Passwordless Sudo (on the storage server)
Edit the sudoers file:
sudo visudo
Add:
jenkins ALL=(ALL) NOPASSWD: /usr/bin/yum
Or, for Ubuntu:
jenkins ALL=(ALL) NOPASSWD: /usr/bin/apt-get
This ensures sudo won't ask for a password during job execution.
π¦ Some Fun Packages to Try
httpd β Apache Web Server
git β Version Control
curl β Command-line HTTP requests
vim β Classic text editor
nmap β Network scanner
tree β View directory structure
β
Results: A Click-Deploy Linux Installer
Now anyone on the team can open Jenkins, enter the package name, hit "Build", and boom π₯ β the software is installed on the remote server!
No SSH.
No typing passwords.
Fully traceable via Jenkins logs.
π¬ Final Thoughts
This setup is perfect for:
Onboarding new servers
Temporary testing environments
Reproducible DevOps workflows
If you're managing infrastructure with Jenkins, adding remote automation like this will save you hours of manual work.
Let me know if youβve used a similar trick β or if you'd like the pipeline version of this!
Until next time,
β Anusha | Data Enthusiast Era π₯
Top comments (0)