Use it to build a secure baseline or check a server against one.
Linux Hardening
Linux hardening applies a baseline: minimal packages and services, automatic security updates, strong authentication, SSH hardening, firewall, MAC enforcing, secure mount options, kernel sysctl settings, auditing and logging. Benchmarks such as CIS describe it.
1. Scan: oscap xccdf eval --profile <cis> … or lynis audit system.
2. Updates automatic? (unattended-upgrades / dnf-automatic)
3. Unneeded services disabled (systemctl list-unit-files --state=enabled).
4. sysctl hardening (net.ipv4.conf.all.rp_filter, kernel.kptr_restrict…).
5. Re-scan after fixes.
baseline defined → applied by automation → scanned → findings fixed → re-scanned
For Security → Linux Hardening, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Linux Hardening. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
ss -tulpnVerification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
host role + threat model → approved baseline → configuration deployment → loaded kernel/service/security state → allow/deny workload tests → audit/drift → remediation/recovery
Healthy evidence: the selected baseline matches host role/version, effective controls are verified, exceptions are documented, drift is monitored and workload/recovery acceptance tests pass
Step 2 Verification and output interpretation Verify boundary
Verification chain. host role + threat model → approved baseline → configuration deployment → loaded kernel/service/security state → allow/deny workload tests → audit/drift → remediation/recovery
Step 3 Commands Verify boundary
lynis audit system
ss -tulpn
systemctl list-unit-files --state=enabled
Step 4 Failure modes and next checks Narrow the fault
Suspicious evidence: wrong distribution guidance, config is not loaded, permissive controls remain, unnecessary services/privilege persist, patch/reboot gaps exist, audit blind spots remain or recovery is broken
Step 5 Common mistakes Narrow the fault
- Hardening without a baseline or testing.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Automate the baseline (Ansible, OpenSCAP) rather than hand-editing. Scan with OpenSCAP (oscap) or Lynis and fix findings by priority. Test services after each hardening change.
sestatus / aa-status— SELinux or AppArmor statess -tulpn— listening servicesjournalctl -u sshd -g 'Failed'— failed loginsausearch -m avc,user_login -ts today— audit events (auditd)
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Hardening is resolved only when controls are appropriate to the host role, effective state matches intent, workload and recovery remain functional, and deviations are explicitly accepted or remediated.
In depth
Harden services with systemd sandboxing
Every exposed service benefits from restrictions applied by the service manager. The systemd.exec manual documents options such as ProtectSystem= (read-only system directories), ProtectHome=, NoNewPrivileges=, PrivateTmp= and CapabilityBoundingSet=.
# /etc/systemd/system/myapp.service.d/hardening.conf
[Service]
NoNewPrivileges=yes
ProtectSystem=strict
ReadWritePaths=/var/lib/myapp /var/log/myapp
ProtectHome=yes
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectControlGroups=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
SystemCallFilter=@system-service
$ systemctl daemon-reload && systemctl restart myapp
$ systemd-analyze security myapp.service
NAME DESCRIPTION EXPOSURE
✗ PrivateNetwork= Service has access to the host's network 0.5
✓ ProtectSystem= Service has strict read-only access to the OS …
→ Overall exposure level for myapp.service: 3.1 OK 🙂
systemd-analyze security scores each unit; start with internet-facing services that score high (UNSAFE/EXPOSED).
Host baseline checklist
| Area | Check |
|---|---|
| Updates | Automatic security updates (unattended-upgrades / dnf-automatic) and reboot policy for kernels |
| SSH | Keys only, no root password login (sshd -T \| grep -E 'permitrootlogin\|passwordauthentication') |
| Listening services | ss -ltnup — remove what is not needed |
| Firewall | Default deny inbound (nft list ruleset) |
| MAC | SELinux enforcing / AppArmor profiles loaded |
| Accounts | No unused accounts with shells; sudo via groups, logged |
| Kernel parameters | sysctl kernel.kptr_restrict kernel.dmesg_restrict net.ipv4.conf.all.rp_filter |
| Logging | Persistent journal or remote log shipping |
Roll out safely
Apply sandboxing options one group at a time and watch journalctl -u myapp for Permission denied, Read-only file system or EPERM — then add the specific ReadWritePaths= or capability instead of dropping the protection.
*The sandbox configuration and systemd exposure assessment are illustrative examples, not a completed security audit.*
How it works at runtime
Linux Hardening is part of Security → Linux Hardening. Linux Hardening applies role- and distribution-specific secure configuration across boot/kernel, identities, services, SSH/PAM, storage, LSMs, firewall, audit, updates, secrets and recovery while controlling drift.
Topic-specific state model. Linux Hardening applies role- and distribution-specific secure configuration across boot/kernel, identities, services, SSH/PAM, storage, LSMs, firewall, audit, updates, secrets and recovery while controlling drift.
Interpretation rule. - Passing a hardening checklist ≠ effective runtime enforcement or acceptable residual risk.
- A generic benchmark item ≠ appropriate policy for every Linux role, distribution or workload.
Method
A practical Linux hardening baseline:
1. Minimal install; remove unused packages and services (systemctl list-unit-files --state=enabled).
2. Automatic security updates (dnf-automatic, unattended-upgrades), kernel live patching where needed.
3. SSH: keys only, no root login, restricted users/groups and source networks.
4. Host firewall default deny inbound.
5. SELinux enforcing / AppArmor enforcing.
6. sudo with named accounts and logging; no shared root password use.
7. auditd rules and central logging; time sync.
8. Filesystem options: nodev,nosuid,noexec on /tmp, /var/tmp, /dev/shm where possible.
9. Kernel sysctls: kernel.kptr_restrict=2, net.ipv4.conf.all.rp_filter=1, fs.protected_symlinks=1.
10. Scan with OpenSCAP/Lynis and track deviations.
lynis audit system
Limits and how it fails
Primary failure point. Hardening is resolved only when controls are appropriate to the host role, effective state matches intent, workload and recovery remain functional, and deviations are explicitly accepted or remediated.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. Linux Hardening owns platform-wide baseline composition; specialist branches own each control’s detailed implementation and evidence.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Security → Linux Hardening. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/security/index.html · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
Linux Hardening operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for Linux Hardening.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Linux Hardening applies role- and distribution-specific secure configuration across boot/kernel, identities, services, SSH/PAM, storage, LSMs, firewall, audit, updates, secrets and recovery while controlling drift. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | host role + threat model → approved baseline → configuration deployment → loaded kernel/service/security state → allow/deny workload tests → audit/drift → remediation/recovery | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Hardening closes only when controls are appropriate to the host role, effective state matches intent, workload and recovery remain functional, and deviations are explicitly accepted or remediated. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux security/trust evidence can establish this proof path: host role + threat model → approved baseline → configuration deployment → loaded kernel/service/security state → allow/deny workload tests → audit/drift → remediation/recovery | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. Hardening closes only when controls are appropriate to the host role, effective state matches intent, workload and recovery remain functional, and deviations are explicitly accepted or remediated. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
Linux Hardening · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | Linux Hardening |
|---|---|
| Topic path | Security → Linux Hardening |
| Runtime state | Linux Hardening applies role- and distribution-specific secure configuration across boot/kernel, identities, services, SSH/PAM, storage, LSMs, firewall, audit, updates, secrets and recovery while controlling drift. |
| Fast checks | - Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for Linux Hardening. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check. |
| Verification chain | host role + threat model → approved baseline → configuration deployment → loaded kernel/service/security state → allow/deny workload tests → audit/drift → remediation/recovery Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | Hardening closes only when controls are appropriate to the host role, effective state matches intent, workload and recovery remain functional, and deviations are explicitly accepted or remediated. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |