DEV Community

Anusha Kuppili
Anusha Kuppili

Posted on

πŸš€ Automate Remote Package Installation with Jenkins | Real-World DevOps

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"
Enter fullscreen mode Exit fullscreen mode

πŸ” 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>
Enter fullscreen mode Exit fullscreen mode

βœ… 2. Passwordless Sudo (on the storage server)
Edit the sudoers file:

sudo visudo
Enter fullscreen mode Exit fullscreen mode

Add:

jenkins ALL=(ALL) NOPASSWD: /usr/bin/yum
Enter fullscreen mode Exit fullscreen mode

Or, for Ubuntu:

jenkins ALL=(ALL) NOPASSWD: /usr/bin/apt-get
Enter fullscreen mode Exit fullscreen mode

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)