Linux Hardening Deep Dive: Baseline bis Audit
Ein technischer Leitfaden: Kernel, systemd, SSH, Rechte, Logging, Audit – mit reproduzierbaren Checks.
Baseline: Zielbild & Geltungsbereich
Definiere zuerst: Server-Rolle, Threat Model, Betriebsanforderungen (Updates, Monitoring, Backup). Dann baust du eine Baseline, die du automatisieren kannst.
- Golden Image / IaC: gleiche Konfiguration überall
- „Drift“ verhindern: Config management + Compliance Checks
- Evidence: Hardening-Report + Abweichungen
SSH & Remote Access (sicher & wartbar)
- PasswordAuthentication no, Pubkey only
- RootLogin prohibit-password (oder no) + getrennte Admin-User
- MFA via SSH CA / Bastion / VPN (je nach Umgebung)
- AllowUsers/AllowGroups + Fail2ban/Rate limiting
Beispiel /etc/ssh/sshd_config:
PermitRootLogin no
PasswordAuthentication no
PubkeyAuthentication yes
AuthenticationMethods publickey
AllowGroups sshadmins
ClientAliveInterval 300
ClientAliveCountMax 2Kernel & sysctl (minimal, aber sinnvoll)
- ASLR aktiv, ptrace einschränken, dmesg restrict
- IPv4/IPv6: Redirects aus, rp_filter passend, source routing aus
- Disable unneeded modules (blacklist) nach Rolle
Beispiel /etc/sysctl.d/99-hardening.conf:
kernel.kptr_restrict=2
kernel.dmesg_restrict=1
kernel.yama.ptrace_scope=2
net.ipv4.conf.all.accept_redirects=0
net.ipv4.conf.all.send_redirects=0
net.ipv4.conf.all.rp_filter=1Firewall (nftables) & Service Exposure
Expose nur, was gebraucht wird. Alles andere: Default deny. Dokumentiere Ports pro Rolle.
nft add table inet filter
nft add chain inet filter input { type filter hook input priority 0; policy drop; }
# allow established/related
nft add rule inet filter input ct state established,related accept
# allow ssh from admin subnet
nft add rule inet filter input ip saddr 10.10.10.0/24 tcp dport 22 accept
# allow icmp
nft add rule inet filter input ip protocol icmp acceptLogging & Audit: Was du wirklich brauchst
- journald persistent (je nach Policy) + Forwarding (rsyslog/syslog-ng)
- auth logs, sudo logs, ssh logs, kernel logs
- auditd: privileged ops, file integrity for critical paths
- Retention: technisch + rechtlich abgestimmt
Compliance Checks (reproduzierbar)
Nutze Tools wie Lynis, OpenSCAP oder eigene Scripts. Wichtig ist: wiederholbar, versioniert, mit Abweichungsbegründung.
- Hardening-Report pro Host/Role
- Abweichungsregister (why/owner/expiry)
- Retest nach Changes