Durcissement SSH, PAM et audit 25 min de lecture

SSH hardening et sudoers

Durcissement SSH

# /etc/ssh/sshd_config
PermitRootLogin no              # Interdire root
PasswordAuthentication no       # Cles uniquement
PubkeyAuthentication yes
MaxAuthTries 3
AllowUsers alice bob            # Liste blanche
Port 2222                       # Changer le port
sudo sshd -t                    # Tester la config
sudo systemctl restart sshd

PAM (Pluggable Authentication Modules)

PAM gere l'authentification de maniere modulaire. Les fichiers sont dans /etc/pam.d/.

sudoers avance

# /etc/sudoers (toujours editer avec visudo)
alice ALL=(ALL) /usr/bin/systemctl restart nginx
bob ALL=(ALL) NOPASSWD: /usr/bin/apt update

Audit

sudo apt install auditd
sudo auditctl -w /etc/passwd -p wa -k passwd_changes
sudo ausearch -k passwd_changes    # Rechercher les evenements