Skip to content

Security Operations / System auditing · Step 5 of 5

Lesson: Configuration ChangesSwitch
← Security Operations

Security investigations

Configuration Changes

Track who changed a configuration file, what changed and whether it was intended.

Many outages and security gaps start with a configuration change. To audit one, you want to know what changed, when, who did it and why.

Notice the change

stat shows when a file's contents were last modified:

bash
$ stat -c '%y %U %n' /etc/ssh/sshd_config
2026-03-03 10:12:44.000000000 +0000 root /etc/ssh/sshd_config

%U is the file's owner, not the person who edited it.

See what differs

Keep a copy before editing, then compare:

bash
$ sudo cp -a /etc/ssh/sshd_config /root/sshd_config.before
$ sudo diff -u /root/sshd_config.before /etc/ssh/sshd_config
-PasswordAuthentication yes
+PasswordAuthentication no

Output is shortened. In diff -u, - marks old lines and + new ones. Package tools help too: rpm -Vc openssh-server on Fedora and RHEL, or dpkg -V openssh-server on Debian and Ubuntu, can show that packaged files differ from what was shipped. On Debian and Ubuntu, /etc/ssh/sshd_config is generated at install time and managed by ucf, so do not expect dpkg -V to report edits to it.

Record who

An audit rule captures the actor:

bash
sudo auditctl -w /etc/ssh/sshd_config -p wa -k sshd-config
sudo ausearch -k sshd-config -i

Look at auid for the login user and exe for the program. The rule records only events after it is added, and it is lost at reboot unless saved under /etc/audit/rules.d/. It also does not store the old and new contents. Combine it with copies or version control.

Includes matter: SSH settings may also live in /etc/ssh/sshd_config.d/, so watch that directory too.

Keep history

Putting configuration in version control records content, author and message for each change. Tools such as etckeeper do this for /etc. Commit authors are only as reliable as your process, and /etc holds secrets, so restrict access to the repository.

Compare with intent

Link each change to a ticket or request. A change with no explanation needs a question. Also check the effective configuration, because a file edit takes effect only when the program loads it:

bash
sudo sshd -t
sudo sshd -T | grep -i passwordauthentication

-t tests validity and -T prints the settings as parsed from the files now. A running service may still use older ones until it is reloaded.

Try it

On a test machine, copy a harmless configuration file, change a comment, and run diff -u. Add an audit watch on your copy and change it again to find the event. The files and links lab helps with file handling.

Check your understanding

Configuration Changes

All 4 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.