DevSecLab Series: Server Setup
Updated: Jun 14, 2021
This post will include step-by-step instructions on how to set up the initial infrastructure of your DevSecOps lab. For this entire lab series, we will be using VirtualBox with a single VM running Ubuntu to configure and setup our environment.
VirtualBox - VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use. Not only is VirtualBox an extremely feature-rich, high-performance product for enterprise customers, it is also the only professional solution that is freely available as Open Source Software under the terms of the GNU General Public License (GPL) version 2. For more information, please visit https://www.virtualbox.org/
Ubuntu 20.04 - Ubuntu is a Linux distribution based on Debian mostly composed of free and open-source software. For more information, visit https://ubuntu.com/
VirtualBox Install & Configuration
Before we began, please ensure that you have Intel VT/AMD-V virtualization enabled in the BIOS, otherwise, VirtualBox will be unresponsive.
In this section, we will be installing and configuring VirtualBox. To install the software, please refer to the link below and download the package for your OS.
Once you have downloaded and installed the program, now you're going to want to download the Ubuntu Server Operating System from the Ubuntu website. Refer to the link below for further instructions.
P.S: Make sure you save that ISO file someplace safe ;)
At this point in the article, you should have downloaded and installed VirtualBox and downloaded the Ubuntu image file. If you're having issues, please respond to this post with your issue and I'll get back to you with a resolution.
Upon opening VirtualBox, you should see a series of buttons in the middle of the application that looks like this:
Click the new button and enter the following:
Name: DevSecLab Image
Machine Folder: This is completely subjective. You can specify where you'd like your newly created virtual image to be created.
Version: Ubuntu (64-bit)
Memory size: I recommend dedicating at least 6GB of memory to this image since we'll be running multiple services at once. The most expensive service will be GitLab, which requires about 4GB of RAM.
Hard Disk: Create a virtual hard disk now
Click create and configure the following settings:
File Location: If you've customized the path on the screen before this, I'd advise you to leave this field alone. It is populated by default.
File-size: 30GB or more.
Hard Disk file type: VDI
Storage on Physical Hard disk: Dynamically allocated. As the image grows, the file itself will automatically scale to accommodate changes.
Once you've clicked create, you should be back at the home screen with this information. Things are about to get interesting from this point forward.
In order to start this image, we need to configure the IDE Secondary Master inside of the storage section to point to the ISO file you've downloaded earlier. You'll want to click "Choose disk image" and find the ISO file and load that.
Afterward, you will click the "Start" button. This concludes the instructions for this section.
Ubuntu Installation and Configuration
In this section, we will be installing and configuring our virtual Ubuntu image. Once you've started the image for the first time, you should be prompted to select a language. Select your language of choice and present Enter.
The next screen will prompt you to update the installer. Let's skip this for now.
Next, you'll need to configure your keyboard settings. Choose your layout and version and select Done.
Next, it will prompt you to configure your network connections, proxy settings, and archive mirror. Just press Enter through these screens.
Once you've gotten through the network configuration pages, we'll reach the Guided storage configuration page. You'll want to use the entire disk and select Done.
The last page will be the Storage configuration summary. You can just press Enter and continue on with the installation.
Afterward, you will enter the Profile setup page. Please fill out that information and click Done.
On the next screen, we'll be asked if we'll like to set up OpenSSH. Press enter and click Done.
The next page will bring you to Featured Server Snap repositories. If you're Linux savvy and see a package you'll like to install, please select it and click Done. Otherwise, click Done and continue.
At this point, you should see the installation log. Step away for a bit and grab your favorite beverage caffeinated beverage of choice. It will take a little while depending on your system's specifications.
After you've had finish your beverage and watched a little bit of Netflix or played a videogame, you should be prompted to enter your credentials. Please enter your username and password and log in to the server.
Before we conclude this section, we need to do one tiny modification to the NAT rules for VirtualBox for this image. Highlight "DevSecLab Image", right-click on it and click on "Settings". You should see a pop-up box like this:
If it defaults to the General tab, that is fine. Click on the Network tab on the left hand side and then click on port forwarding in the Advanced dropdown tab in the middle of the form. Afterward, copy the configuration as shown below:
By creating new rules and assigning these ports, we will be able to access services from outside the VM. For example, we should be able to ssh into our Ubuntu instance from our local machine, or another machine on the network, by running this command:
$ ssh -p 8022 damien@localhost
As we continue to install new software, we will be returning to add more port forwarding rules to access the web interfaces from our local machines.
Yaaaayyy!!! We've finished installing and configuring Ubuntu! Give yourself a pat on the back!
Thank you for reading and following along!