Linux Server Hardening Checklist

A repeatable baseline for Debian and RHEL hosts: accounts, SSH, kernel parameters, auditing and drift control.

Published Nov 13, 2026Updated Nov 13, 20261 min read5 views
  • automation
  • linux
  • security

Accounts and sudo

  • No shared accounts, no direct root login, no passwords on service accounts.

  • Sudo rules scoped to commands, not ALL, for anything routine.

  • Every account maps to a person or a documented system owner.

SSH baseline

Bash
# /etc/ssh/sshd_config.d/10-hardening.conf
PermitRootLogin no
PasswordAuthentication no
KbdInteractiveAuthentication no
PubkeyAuthentication yes
AllowGroups ssh-users
MaxAuthTries 3
ClientAliveInterval 300
ClientAliveCountMax 2
X11Forwarding no
Ciphers [email protected],[email protected]
KexAlgorithms curve25519-sha256,diffie-hellman-group16-sha512

Kernel and network parameters

Bash
# /etc/sysctl.d/60-hardening.conf
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.tcp_syncookies = 1
net.ipv6.conf.all.accept_ra = 0
kernel.kptr_restrict = 2
kernel.dmesg_restrict = 1
fs.protected_hardlinks = 1
fs.protected_symlinks = 1

Auditing and integrity

Bash
apt-get install -y auditd aide
aideinit && mv /var/lib/aide/aide.db.new /var/lib/aide/aide.db
auditctl -w /etc/ssh/sshd_config -p wa -k sshd_config
auditctl -w /etc/sudoers.d/ -p wa -k sudoers

Make it repeatable

A checklist applied by hand decays within a quarter. Encode it as configuration management and run it on a schedule so drift is corrected, not merely detected.

YAML
- name: Harden SSH
  ansible.builtin.template:
    src: 10-hardening.conf.j2
    dest: /etc/ssh/sshd_config.d/10-hardening.conf
    mode: "0644"
    validate: /usr/sbin/sshd -t -f %s
  notify: restart sshd

Verify

Bash
ss -tulpn | grep LISTEN
systemctl list-unit-files --state=enabled | wc -l
lynis audit system --quick

Back to all docs