Episode 204 was about turning off what you don't need. This week's Into the Terminal (episode 205) is the sequel: harden what you can't get rid of. Scott and Nate layer defense in depth on a RHEL box — filesystem mount options that stop planted binaries from becoming root, a live tcpdump of passwords flying across the wire in cleartext (and the same request vanishing under TLS), one-command system-wide crypto policy, and a full MariaDB hardening walkthrough that includes the SELinux denial you shouldn't "fix" with setenforce 0.
Full video here → https://www.youtube.com/watch?v=EDrPZT-TvX4 More hands-on RHEL practice → https://redhat.com/interactive-labs
The Essentials: Filesystem Mount Options Are Security Controls
Compliance frameworks don't just ask for fancy partitioning so your disk layout looks impressive. Separate mounts for things like /tmp, /var, and /home do two jobs:
Contain disk-full disasters — if /var fills up, logging and services get unhappy, but you can still log in and read /etc
Give you different mount options per filesystem — you can't slap noexec on / without breaking sudo, ls, and everything else you need
Scott mounted a tiny demo filesystem on /mnt and dropped three "interesting" files on it: a setuid copy of sudo, a setgid write binary, and a tiny shell script. Colorized ls made the special bits obvious. Running the planted sudo as a normal user escalated to root — because setuid does what it says on the tin, even when the binary is sitting in a weird directory instead of /usr/bin.
| Mount option | What it does |
|---|
nosuid | Ignores setuid and setgid bits — planted root-setuid binaries can't escalate |
noexec | Nothing on this filesystem can be executed (even if the execute bit is set) |
nodev | Device nodes created with mknod aren't honored — kills planted /dev/sda-style tricks |
# Live remount for testing (gone on reboot)
mount -o remount,nosuid /mnt
mount -o remount,noexec /mnt
mount -o remount,nosuid,nodev,noexec /mnt
# Make it stick — add the options in /etc/fstab, then:
umount /mnt
mount -a # re-read fstab and attach everything
mount | grep /mnt # confirm the options stuck
Pro tips from the show:
Test with mount -o remount,... first (like firewall rules in memory) — if you brick something, a reboot still saves you. Writing a broken entry straight into /etc/fstab means the next reboot puts you right back in the broken state.
After editing fstab, mount -a is how you find out now whether the syntax is good — don't wait for reboot day.
You need the more complex partition layout for this to work. One big / filesystem means you can't noexec/nosuid the places users can write without also breaking legitimate system binaries.
Nate ran a Summit booth challenge years ago that was literally "why won't my script run?" with /tmp mounted noexec. Plenty of working Linux admins couldn't solve it. Common ≠ known.
(Spaces vs tabs in fstab: Scott lined things up with spaces. Nate called him a heathen. Tab stops entered the chat.)
Harden the Wire: Plaintext vs. Encrypted
Nate's first packet-capture demo still feels like a superpower the first time you see it — and that's the point.
| Command | What it does |
|---|
tcpdump -i any -n -A 'tcp port 80' | Capture HTTP in cleartext (ASCII payload dump) |
curl -d 'user=admin&password=SuperSecret123' http://127.0.0.1/ | POST "secrets" over plain HTTP |
tcpdump -i any -n -A 'tcp port 443' | Same capture on HTTPS |
curl -k -d 'user=admin&password=SuperSecret123' https://127.0.0.1/ | Same POST over TLS (-k = accept self-signed) |
On port 80, the capture shows the POST body in cleartext — username, password, the whole request. On port 443 with mod_ssl's out-of-the-box self-signed cert, that same payload is just TLS noise. You can't read it.
Takeaways they hammered:
A self-signed cert encrypts just as well as a CA-signed one. The CA adds trust (browsers/clients accept the identity without warnings), not stronger crypto. Key length and algorithms determine how hard it is to crack.
Protect the private key. Heartbleed (over a decade ago) was scary specifically because it could leak keys from memory — and with the key, you can impersonate the service.
Open Wi-Fi (Starbucks "click I agree" portals with no password) is often cleartext between you and the AP. Encrypt your own sessions (TLS, VPN) regardless.
Switched wired networks usually only show you your own traffic unless there's a SPAN/mirror port. Wi-Fi on the same AP is a different story.
Advanced: Raise the Crypto Floor System-Wide
Hand-tuning OpenSSH, OpenSSL, GnuTLS, NSS, Kerberos… forever is a losing game. RHEL gives you one knob: system-wide crypto policies.
| Command | What it does |
|---|
update-crypto-policies --show | Print the active policy (usually DEFAULT out of the box) |
update-crypto-policies --set FUTURE | Raise the floor — refuse weaker algorithms/key sizes |
update-crypto-policies --set DEFAULT | Back to the sane modern baseline |
update-crypto-policies --set LEGACY | Loosen for ancient gear (going the wrong way — last resort) |
update-crypto-policies --set DEFAULT:NO-SHA1 | Surgical subpolicy: keep DEFAULT, kill SHA-1 signatures |
Built-in policies worth knowing: DEFAULT, FUTURE, LEGACY, and FIPS (pairs with fips-mode-setup — its own rabbit hole).
What FUTURE actually breaks (live demo)
Scott flipped the box to FUTURE, then systemctl restart httpd — Apache refused to start. The smoking gun in /var/log/httpd/ssl_error_log: the default mod_ssl certificate key was too small. FUTURE wants something stronger than a 2048-bit RSA key (think 3072+ minimum); the stock self-signed cert was 2048.
# Generate a FUTURE-compliant self-signed cert (4096-bit)
openssl req -x509 -nodes -days 365 -newkey rsa:4096 \
-keyout /etc/pki/tls/private/localhost.key \
-out /etc/pki/tls/certs/localhost.crt \
-subj "/CN=$(hostname)"
systemctl restart httpd # now starts under FUTURE
Caveats from the show:
After changing policy, reboot (or at least restart crypto-using services). Already-running processes keep the old policy in memory.
Distro packages that use the system crypto libraries honor the policy. Containers, Flatpaks, and third-party apps (Chrome was the example) often ship their own crypto stacks and ignore the host policy entirely.
Stronger crypto = more math per connection. Fine for low-volume boxes; measure CPU on high-connection services.
Post-quantum: Nate's take — if you're standing up a new box today, enable quantum-safe algorithms from day one. RHEL 10 does this by default; RHEL 9 makes it an option. Older distros often don't have the algorithms at all.
Advanced: Harden a Real Service End-to-End (MariaDB)
Fresh dnf install + enable. No databases, no passwords — stock out of the box. RHEL ships services a bit more locked down than many community distros, but "a little hardened" ≠ "done."
1. See where it's listening
ss -tulnp | grep 3306
Out of the box: 0.0.0.0:3306 and [::]:3306 — every IPv4 and IPv6 interface. Dual-stack is the default on modern RHEL; firewalling only IPv4 and forgetting IPv6 is a classic footgun.
2. Bind to localhost
Edit /etc/my.cnf.d/mariadb-server.cnf, under [mysqld]:
bind-address=127.0.0.1
systemctl restart mariadb
ss -tulnp | grep 3306
# → 127.0.0.1:3306 only (IPv6 listener gone too, because you pinned a v4 address)
Same localhost-binding idea they previewed with Postgres in ep. 204. If the DB only needs local app access, don't put it on the network.
(Why [mysqld] not [mariadbd]? MariaDB forked from MySQL after license drama; config blocks and CLI tools stayed compatible for years so people weren't stranded.)
3. "Just change the port" — and the SELinux lesson
Changing port=3307 and restarting → MariaDB refuses to start. Not a typo — SELinux denied the bind.
sudo ausearch -m avc -ts recent
# look for: avc: denied { name_bind } ... comm="mariadbd" ... src=3307
# Wrong fix: setenforce 0
# Right fix:
sudo semanage port -a -t mysqld_port_t -p tcp 3307
systemctl restart mariadb
Apache often already allows 80/443/8080/8443. MariaDB's allowed port list is tighter. Teach SELinux the new port; don't turn it off.
And this still isn't "security." Nate's Windows SQL Server story: the boss insisted on checking "Hide SQL Server," which just added 1000 to the port (1433 → 2433). Attackers added 2433 to their scan lists. Security by obscurity is at best one thin layer — never the plan.
4. Run mariadb-secure-installation
The bundled wizard walks common hygiene:
| Step | Why it matters |
|---|
| Switch root to UNIX socket auth | Root DB access tied to the local Linux account / socket — not a network password |
| Set a root password | Out-of-box often has none |
| Remove anonymous users | Default anonymous accounts are free attack surface |
| Disallow remote root login | Defense in depth even after socket auth |
| Remove the test database | Optional in labs / handoff environments; usually gone before prod |
| Reload privilege tables | Apply now, or defer to a maintenance window |
5. More you can still do (discussed, not fully demoed)
| Hardening idea | Why |
|---|
local-infile=0 | Disable LOAD DATA LOCAL INFILE — harder for a compromised client/session to slurp files off the server |
| Password validation plugin | Enforce password quality at the DB layer |
Scope your GRANTs | GRANT ALL … TO user@'%' is the most common real-world sin — grant only what's needed, only from the expected host |
Apply the same mindset to SSH, httpd, or anything else you leave running: evaluate the out-of-box defaults against your threat model, then turn off what isn't serving you.
Related episodes
Quick Reference Card
# --- Filesystem hardening ---
mount -o remount,nosuid,nodev,noexec /mnt
# then persist options in /etc/fstab and verify with:
umount /mnt && mount -a && mount | grep /mnt
# --- See cleartext vs TLS ---
tcpdump -i any -n -A 'tcp port 80'
curl -d 'user=admin&password=SuperSecret123' http://127.0.0.1/
tcpdump -i any -n -A 'tcp port 443'
curl -k -d 'user=admin&password=SuperSecret123' https://127.0.0.1/
# --- System-wide crypto policy ---
update-crypto-policies --show
sudo update-crypto-policies --set FUTURE # then reboot / restart services
sudo update-crypto-policies --set DEFAULT
sudo update-crypto-policies --set DEFAULT:NO-SHA1
tail /var/log/httpd/ssl_error_log # when httpd refuses after FUTURE
openssl req -x509 -nodes -days 365 -newkey rsa:4096 \
-keyout /etc/pki/tls/private/localhost.key \
-out /etc/pki/tls/certs/localhost.crt \
-subj "/CN=$(hostname)"
# --- MariaDB hardening ---
ss -tulnp | grep 3306
# /etc/my.cnf.d/mariadb-server.cnf → bind-address=127.0.0.1
# optional: port=3307 then:
sudo ausearch -m avc -ts recent
sudo semanage port -a -t mysqld_port_t -p tcp 3307
systemctl restart mariadb
mariadb-secure-installation
Links
Into the Terminal is a (mostly) weekly live show where Red Hatters dig into Linux and RHEL administration skills — one terminal command, one bad pun, and one "oops, wrong window" at a time.