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 chacha20-poly1305@openssh.com,aes256-gcm@openssh.com
KexAlgorithms curve25519-sha256,diffie-hellman-group16-sha512Kernel 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 = 1Auditing 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 sudoersMake 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 sshdVerify
Bash
ss -tulpn | grep LISTEN
systemctl list-unit-files --state=enabled | wc -l
lynis audit system --quick