Sub topic 16
Verify the Baseline with a Checklist
A server that "seems fine" after setup is not the same as a server you have checked. This chapter gives you a repeatable set of commands that confirm the baseline from the earlier chapters: network, SSH, firewall, time, updates, services and logs. You run the same checks after every install, so differences between servers show up quickly.
Prerequisites
This chapter assumes you have:
- A freshly installed server with an admin user that can use
sudo. - Key-based SSH login working, with password and root login disabled.
- A host firewall enabled (ufw or firewalld).
- Basic familiarity with
systemctland reading command output.
Why a checklist and not a feeling
Each setup step can fail quietly. A firewall can be installed but not enabled. An SSH setting can sit in a file that another file overrides. A unit can fail at boot while the system still looks usable. A checklist turns "I think it works" into evidence you can compare between servers and over time.
Three rules make the checklist useful:
- Run it from a fresh login, not from a shell you have had open for hours.
- Compare each result with an expected value you wrote down beforehand.
- Keep the output. If the server later misbehaves, you can compare it with the baseline.
The checklist at a glance
Step 1: network
ip -br addr
ip route
resolvectl statusip -br addr prints one line per interface with its state and addresses. Expect the main interface to show UP and the address you planned, whether static or from DHCP. ip route should show a default route through your gateway. resolvectl status shows which DNS servers are in use. This command exists only on systems running systemd-resolved. On other systems, read /etc/resolv.conf instead.
A quick end-to-end test confirms that routing and DNS both work:
ping -c 2 1.1.1.1
getent hosts example.comIf the first command succeeds and the second fails, routing is fine and DNS is the problem.
Step 2: what is listening
ss -tlnpThe flags mean: -t TCP, -l listening sockets only, -n numeric ports, -p the owning process. Running with sudo is needed to see process names for sockets you do not own.
On a minimal server, expect SSH on port 22 and little else. A resolver stub on 127.0.0.53 or 127.0.0.54 is normal on systems using systemd-resolved. Anything listening on 0.0.0.0 or [::] that you did not install on purpose deserves an explanation.
| Listening address | Meaning | Action |
|---|---|---|
| `127.0.0.1:port` | Reachable only from this host | Usually fine |
| `0.0.0.0:port` | All IPv4 interfaces | Confirm the firewall controls it |
| `[::]:port` | All IPv6 interfaces | Check IPv6 firewall rules too |
| `192.0.2.10:port` | One specific address | Confirm it is intended |
Step 3: SSH and firewall
Do not read the SSH config files and guess. Ask the daemon what it is actually using:
sudo sshd -T | grep -Ei '^(passwordauthentication|permitrootlogin|pubkeyauthentication)'sshd -T prints the effective configuration after all files are merged. The expected output is:
permitrootlogin no
pubkeyauthentication yes
passwordauthentication noIf passwordauthentication shows yes, another file is overriding your drop-in. OpenSSH uses the first value it finds for each keyword, and files in sshd_config.d are read in alphabetical order. A file named 01-cloud.conf can therefore win over 10-hardening.conf.
Then check the firewall:
# Ubuntu with ufw
sudo ufw status verbose
# RHEL family with firewalld
sudo firewall-cmd --list-allExpect the firewall to be active, incoming traffic denied by default, and only SSH allowed. Compare this list with the output of ss -tlnp. Every port the firewall allows should have a service behind it, and every service you want reachable should have a rule.
A last test must come from another machine, because a firewall test from the server itself proves little:
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no [email protected]This should fail with Permission denied (publickey). If it asks for a password, password login is still on.
Step 4: time and hostname
timedatectl status
hostnamectlIn timedatectl output, look for System clock synchronized: yes and the timezone you chose. If it says no shortly after boot, wait a minute and run it again. Time sync can take a short while to start. If it stays no, check the time service with systemctl status systemd-timesyncd or systemctl status chronyd, depending on the distribution.
In hostnamectl, confirm the static hostname matches your plan, for example web01.
Step 5: updates
# Debian/Ubuntu
sudo apt update
apt list --upgradable
systemctl status unattended-upgrades
# RHEL family
sudo dnf check-update
systemctl list-timers 'dnf-automatic*'On Debian-based systems the upgradable list should be empty or contain only packages you chose to hold. On the RHEL family, dnf check-update exits with code 100 when updates are available and 0 when there are none, so check the exit code in scripts rather than treating 100 as an error.
Also check whether a reboot is pending. A kernel update does not take effect until you reboot:
# Debian/Ubuntu
[ -f /var/run/reboot-required ] && echo "reboot required"
# RHEL family (needs the dnf-utils package)
sudo needs-restarting -rStep 6: failed units, disk and logs
systemctl --failed
df -h
journalctl -p err -bsystemctl --failed should report 0 loaded units listed. df -h shows filesystem usage. A new server should be well below capacity. journalctl -p err -b lists messages of priority err and higher since the current boot.
Some errors on a fresh install are harmless, such as a missing optional hardware driver in a virtual machine. Do not ignore them blindly. For each message, decide whether it is explained, and write down the ones you accept. Next time you can tell old, accepted errors from new ones.
A script that runs the whole checklist
Typing every command by hand invites skipped steps. This script prints each section with a header so the output can be saved and compared. It reads state only and changes nothing.
#!/usr/bin/env bash
# baseline-check.sh - read-only baseline report
set -u
section() { printf '\n== %s ==\n' "$1"; }
section "Interfaces"; ip -br addr
section "Routes"; ip route
section "Listening TCP"; sudo ss -tlnp
section "Effective sshd"; sudo sshd -T | grep -Ei '^(passwordauthentication|permitrootlogin|pubkeyauthentication)'
section "Time"; timedatectl status
section "Hostname"; hostnamectl --static
section "Failed units"; systemctl --failed --no-legend
section "Disk"; df -h -x tmpfs -x devtmpfs
section "Errors this boot"; journalctl -p err -b --no-pager | tail -n 20Save it and keep a copy of each run:
chmod +x baseline-check.sh
./baseline-check.sh > "baseline-$(hostname)-$(date +%F).txt"Later, diff against an earlier file shows what changed. Expect differences in disk usage and timestamps. Look for new listening ports, new failed units and changed SSH settings.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| `sshd -T` shows `passwordauthentication yes` | An earlier-sorted drop-in file overrides yours | List `/etc/ssh/sshd_config.d/` and rename or edit the file that wins |
| Port is listening but unreachable from outside | Firewall blocks it | Add an explicit allow rule, then reload |
| Service reachable from outside that you did not expect | It listens on `0.0.0.0` and the firewall allows it, or the firewall is inactive | Bind it to localhost or remove the rule |
| `System clock synchronized: no` | Time service stopped or blocked from reaching its servers | Check the service status and outbound UDP port 123 |
| `dnf check-update` appears to fail | Exit code 100 means updates are available | Read the exit code, not just the status |
| A newly updated kernel is not running | No reboot yet | Compare `uname -r` with the installed kernel and reboot in a maintenance window |
What to do with the result
If everything matches, store the report with your server notes. It is your record of the known-good state. In the later chapters on snapshots and automated installs, this record tells you what a rebuilt server must look like.
If something does not match, fix it and rerun the check from the beginning. A later fix, for example a firewall change, can alter an earlier result, such as the reachable ports.
Exercises
Exercise
You run ss -tlnp on a new server and see a service listening on 0.0.0.0:5432 that you did not install on purpose. The firewall status shows only SSH allowed. Is the service reachable from other machines, and what should you still do?
Show answer
With a working default-deny incoming firewall allowing only SSH, outside machines cannot reach port 5432, so the firewall is protecting it. You should still find out why it is installed and listening (for example with the process name from ss -tlnp and systemctl status), then remove it or bind it to 127.0.0.1. Relying only on the firewall leaves the service exposed if the firewall is later disabled or misconfigured.
Exercise
sshd -T reports passwordauthentication yes, but your file /etc/ssh/sshd_config.d/10-hardening.conf sets it to no. What is the most likely cause and how do you find it?
Show answer
Another configuration file is setting the value first. OpenSSH uses the first value it reads for a keyword, and drop-in files are read in alphabetical order, so a file such as 01-cloud.conf can override 10-hardening.conf. Run grep -ri passwordauthentication /etc/ssh/ to find every setting, change or rename the file that wins, run sudo sshd -t, reload the service, and rerun sudo sshd -T.
Exercise
On a RHEL-family server, a script runs dnf check-update and treats any nonzero exit status as a failure. Why is that wrong?
Show answer
dnf check-update returns 100 when updates are available, 0 when none are, and 1 on an error. Only exit codes other than 0 and 100 indicate a real failure, so the script should accept 100 as a normal result.