Installing and Hardening an Ubuntu Server

From Stiles Wiki
Revision as of 09:15, 11 July 2020 by Maxwells (talk | contribs)
Jump to navigation Jump to search

This guide will help you install, configure, and secure a golden image for your Ubuntu servers.

Requirements

This guide assumes you know the basics of installing an operating system on a computer.

Installing the Ubuntu Server

This should be a pretty standard answer the questions and follow the directions on screen. If you want a static IP address you can set it here, but I like to set a static address through DHCP instead of on the actual server. I also like to use LVM for the disk set ups.

Update and Configure

After you've finished installing the OS, it's time to connect to the server and begin updates and a base configuration. I connect through SSH, but you can do it the physical box if you want. I've found that if you don't make any changes to the default disk settings, you fill up the disk very quickly. Let's change that first, we need to resize the logical volume to use all the existing and free space of the volume group.

sudo lvm
lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
exit

And then, we need to resize the file system to use the new available space in the logical volume. After that's done, we should make sure that it shows the new disk size.

sudo resize2fs /dev/ubuntu-vg/ubuntu-lv
df -h

Next, let's get the latest updates for the server and remove any space wasters.

sudo apt update && sudo apt -y upgrade && sudo apt -y autoremove

Now we need to configure the timezone and our charset. If you want to enable unattended upgrades, now is a good time to do that as well.

sudo dpkg-reconfigure tzdata && locale-gen en_US.UTF-8 && dpkg-reconfigure locales && dpkg-reconfigure -plow unattended-upgrades

Securing the Server

Configuring the Firewall

Installing Fail2Ban

Securing SSH