You will take a raw Linux install and turn it into a consistent, patched, secure baseline every other server inherits. By the end the host is fully updated, time-synced, and managed through a non-root sudo account.

Learning Objectives

  • Patch the system and enable automatic security updates.
  • Set hostname, timezone, and time synchronization.
  • Create a non-root administrative user.
  • Time: ~1 hour · Difficulty: Beginner · Prereqs: a fresh VM with sudo access.

Architecture Overview

Environment Setup

You will need: the VM from the install lab with internet access and sudo.

Before you begin: confirm time and date are roughly correct so package signatures validate.

Prerequisites

  • A freshly installed Debian/Ubuntu server (see the install VM lab) with internet access.
  • Root or console access for the first login before SSH hardening.
  • Know your intended hostname and timezone (America/Toronto used here).
  • A username for the daily-driver sudo account.

Step-by-Step Execution

01
Update the package index and upgrade

Patching first closes known vulnerabilities before the host does anything else.

sudo apt update && sudo apt full-upgrade -y
[ROOT REQUIRED] Refreshes the package list and applies all updates.

Expected output:

Reading package lists... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove

What this teaches: Updating the index before upgrading ensures you patch against current metadata; full-upgrade handles dependency changes that plain upgrade would hold back.

02
Enable automatic security updates

Unattended-upgrades applies security patches without manual intervention, shrinking your exposure window.

sudo apt install -y unattended-upgrades && sudo dpkg-reconfigure -plow unattended-upgrades

Expected output:

Updating certificates in /etc/ssl/certs...
(unattended-upgrades configured and enabled)

What this teaches: unattended-upgrades applies security patches on a schedule, shrinking the window between disclosure and patching without manual intervention. Note: dpkg-reconfigure writes /etc/apt/apt.conf.d/20auto-upgrades to opt in; the schedule itself lives in the apt-daily-upgrade.timer, not in an enabled service unit.

03
Set hostname, timezone, and NTP

Consistent identity and accurate time are prerequisites for correlating logs across hosts.

sudo hostnamectl set-hostname srv01 && sudo timedatectl set-timezone America/Toronto && sudo timedatectl set-ntp true

Expected output:

(no output on success; verify with: hostnamectl && timedatectl)

What this teaches: hostnamectl sets the static identity; timedatectl sets zone and enables NTP so logs correlate across hosts to the second.

04
Create a non-root sudo user

Daily work should never use root directly; a sudo user gives auditable, revocable elevation.

Expected output:

$ sudo adduser taki && sudo usermod -aG sudo taki
Adding user `taki' ... Adding user `taki' to group `sudo' ...

What this teaches: A non-root sudo user gives auditable, revocable elevation; adduser creates the account interactively while usermod -aG appends the sudo group.

How It Works

Post-install hardening follows a simple principle: reduce, then maintain. Patching first closes every known vulnerability before the host takes on a role; automatic security updates keep that posture without relying on human memory. A host that starts fully patched and stays patched is dramatically cheaper to defend than one remediated later.

Identity and time are the two prerequisites for coherent operations. The hostname is how the machine refers to itself in logs, prompts, and monitoring; consistent naming (srv01, not localhost) makes fleet management possible. Accurate time via NTP underpins TLS validation, Kerberos, and cross-host log correlation, which is why timedatectl set-ntp true is non-negotiable.

The non-root user rule exists for accountability. Shared root passwords cannot be revoked per person and leave no audit trail; per-user accounts with sudo log who elevated and when. Disabling direct root SSH later completes the pattern, but creating the sudo user is the step that makes it possible.

Progress So Far

Testing & Validation

Run this final check:

timedatectl status && id taki && systemctl is-enabled apt-daily-upgrade.timer && grep Unattended-Upgrade /etc/apt/apt.conf.d/20auto-upgrades

You should see NTP active, the user in the sudo group, the apt-daily-upgrade.timer reporting enabled, and APT::Periodic::Unattended-Upgrade "1"; in the config. If all checks pass, your baseline is ready. Note: systemctl is-enabled unattended-upgrades reports static because that service has no [Install] section; the timer is the correct thing to verify.

Troubleshooting

SymptomLikely causeFix
apt update hits 404 errorsStale mirror entries or a release that moved to old-releasesCheck sources.list against the current release codename and pick a working mirror
unattended-upgrades never seems to runTimer disabled or package only half-configuredVerify with systemctl status unattended-upgrades and check /var/log/unattended-upgrades/
timedatectl: NTP not synchronizedUDP 123 blocked or no NTP servers reachableOpen NTP egress and confirm with timedatectl timesync-status
New user cannot sudoNot actually in the sudo groupConfirm with id username and re-add with usermod -aG sudo
Hostname reverts after reboot (cloud)Cloud-init rewrites it from metadataSet preserve_hostname: true in cloud-init config
full-upgrade wants to remove packagesDependency resolver cleaning up transitionsReview the list; use apt upgrade for conservative runs on critical hosts
Troubleshooting
  • apt update fails with signature errors: the clock is wrong; set time with sudo timedatectl set-ntp true and retry.
  • sudo: user not in sudoers: re-run usermod -aG sudo taki and start a fresh login.
  • Held-back packages: run sudo apt full-upgrade rather than plain upgrade.

Extension Ideas

Key Results

  • Brought a fresh host to a fully patched state in one pass.
  • Enabled automatic security updates, reducing the patch gap to under 24 hours.
  • Replaced direct root use with an auditable sudo account.
  • Standardized hostname, timezone, and NTP for log correlation.

Key Takeaways

  • Patch before configuring; a fresh host is at its most vulnerable.
  • Automatic security updates shrink the exposure window.
  • Hostname plus NTP are prerequisites for sane logs and TLS.
  • Daily work happens as a sudo user, never as root.
  • Verify each step (id, timedatectl) before moving on.

Practice Challenges

Challenge 1: Reboot-proof identity

Goal: set hostname, timezone, and NTP, reboot, and prove all three persisted.

Hint: hostnamectl and timedatectl status after the reboot.

Challenge 2: SSH lockdown follow-up

Goal: as the new sudo user, disable root SSH login and password auth, then verify you can still get in with your key.

Hint: keep one working session open while testing.