Performing Auto Updates with Jenkins

An important part of network maintenance is keeping your operating system and programs updated. However, if you have a lot of physical or virtual devices the process of keeping everything updated can become tedious. You could create an automated task using a scheduler, but then checking up on each to ensure the scheduled task executed could again become very tedious.

This is where Jenkins comes in. Jenkins is a continuous integration tool which not only can build and test software , but it can also be used to perform scheduled tasks. To execute commands on various machines takes a bit of setup, but in the end you have a nice dashboard which shows you when your tasks were last completed, if they were successful, and when they should run again.

My network is primarily composed of virtual machines running CentOS. This article assumes you have already configured Jenkins on your network. The following SSH plugins for Jenkins were also installed:

  • Publish Over SSH
  • SSH Agent Plugin
  • SSH Credentials Plugin
  • SSH Plugin

To perform an update on a machine the following command is used:

sudo yum update -y

The command must be run with super user privileges. This usually requires a password to be entered. This article will take you through the steps to run the command from Jenkins over SSH on each machine requiring the update without entering a password.

The first step is creating your public/private key pair on Jenkins. This is done from the Jenkins home directory using the command:

ssh-keygen -t rsa -b 1024

This command generates an RSA key pair with 1024 bits in the .ssh directory. Be sure to remember the passphrase as you will need it again. The file named id_rsa is the private key and is the public key.

In the Publish over SSH section of the Jenkins configuration you need to copy the contents of the private key to the key section and enter the passphrase. You will come back to this section after you have configured the servers you wish to connect with via SSH.

On the machine being updated log in and create a jenkins user. This is done with the following two commands:

sudo useradd jenkins
sudo passwd jenkins

Next change to the jenkins user with:

sudo su - jenkins

Once you have changed to the Jenkins user execute the following in the Jenkins home directory:

mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys

In the editor you need to copy the contents of the public key to the file and then save. Next execute:

chmod 600 .ssh/authorized_keys

It’s very important the read/write permission are set or Jenkins will not be able to log in. As root on the remote machine you need to edit the sudoers file. You do this by executing:


You will need to locate the line in the file which read Defaults requiretty and comment it out by using the hashtag. Commenting this line allows Jenkins to run the sudo command. However, normally sudo would require a password. To prevent the password from being needed you need to add the following to the end of the file.


Now you are finished with the remote machine. Next, you need to go back to Publish over SSH in the Jenkins configuration and add your SSH server. Provide the name, hostname, and username to login with. For this article jenkins was used. Your setup should look similar to this:



Now create a Jenkins project and add a Send files or execute command over SSH task. It could look like this:


In the ssh setup section here select the advanced features and set the timeout for your task. At this point you should be able to execute the Jenkins project which will in turn run the update command via SSH as the jenkins user. Because of the changes to the sudoers list, no password will be required and the update will be accomplished.

In the end you will have a history of the updates on your network machines and also be able to view the console output resulting from the update.

Me and Social Media

It has been a long time since I have made any post on Facebook. However, it’s not because I don’t use Facebook anymore. I have just decided to use a different medium for communicating and it has taken a while to get things set up.

My family and friends have commented they do not see much activity from me anymore on Facebook. There are several reasons. One, it just was taking up a lot of my time. Second, it is really hard to keep track of everyone among the Facebook News Feed. I do scan Facebook and see what is going on among the people I call friends and it is great to see the good news. For example, to see individuals progressing in their Air Force careers, or seeing two people getting married, seeing what my cousins are up to, and seeing a friend who is traveling the world and shares through photos. These are all wonderful.

Since retiring from the Air Force last year, my new job has exposed me to a lot of technical stuff I have always had an interest in, but never knew a great deal about. As I have learned more about creating and configuring networks for specific purposes, I decided to set up my own network for hosting software development tools and a personal blog. I will start writing articles about things which are important to me and the activities my family and I participate in and share them through Facebook.

You will more than likely find my posts to be much longer than the traditional Facebook post. However, I will not be posting as often. I hope you enjoy reading my articles. Feel free to message me anytime, as it is always great to hear from friends.


What Is a Home Network?

To many, the idea of a home network may be something that they would never consider. I suppose you may at first just need to understand what a network even is. Well, in my mind a network is nothing more than a number of interconnected computers which each have a specific task. According to Wikipedia:

A computer network or data network is a telecommunications network which allows computers to exchange data. In computer networks, networked computing devices exchange data with each other along network links (data connections). The connections between nodes are established using either cable media or wireless media. The best-known computer network is the Internet.

Now, you might next think, “…he just said a number of interconnected computers. I don’t have a bunch of computers laying around!” Well, you really do not need a bunch of computers to create your home network. You could create the entire network with just one computer.

I myself have access to several computing devices. Tower PCs, tablets, laptops, and smart phones. All of these can become part of your home network. Since we are in a wireless age and most homes have wireless routers, these devices all become interconnected. They may not share data between each other but they do connect to the same home network to access the global network called the internet.

So why a home network? For me I wanted to have access to various tools I use in my software engineering practices:

  • Project Management Tool
  • Continuous Integration Tool
  • Version Control Tool
  • Blogging Tool

To make all of the above things possible I wanted to create a computer for each, and as I mentioned above I don’t have a lot of computers lying around to put all of this together. So, I decided to go the route of a physical host computer and then create the individual virtual machines (VMs) that I would need to make all of this happen.

The physical host is an actual computer and the VMs are computers which only exist within the physical device. Essentially a software computer. Another aspect of this is which operating system (OS) you should use. Microsoft products, unfortunately, require costly product licenses to use. Therefore, I chose to implement all of these “computers” using free open source software. All of the software tools I chose to use are in fact free.

There are several different ways you could implement your home network. The way I chose is just one option. It does function for me and it has been relatively low cost to put together. In future posts, I will describe the components used to create my home network. Many of these I will bet you already have in your home and with a little bit of work they can be put to work to satisfy your home networking needs.

First Post!

For many years I have worked with computers. Both for relaxation at home and as part of my professional life. However, most of the time I have a notebook or a wiki that is used for maintaining historical information about projects that I work on.

I enjoy sharing my projects with others whenever possible. Usually, I talk with my wife about my projects and I have a small group of friends to discuss them with as well. Recently, I decided that I would like to try and share these activities with a larger audience.

I am tech guy. My primary focus for the last ten years has been software development, but recently I have started diving into various other technologies. These new technologies have required a significant amount of research to implement. I decided, since I am using books and posts of others to learn how to solve each piece of my technology puzzle, I would like to share what I have learned as well.

I have quite a few things in mind to share. I hope you will enjoy the posts and visit my site frequently.