Hardening básico: SSH + UFW + Fail2ban
Objetivo: endurecer acceso SSH y reducir superficie de ataque sin meter bloat.
Alcance: Ubuntu 22.04/24.04.
Notas: No guardar secretos aquí. Este runbook se ejecuta con usuario con sudo.
1) SSH (solo llaves, sin root)
Respaldar y configurar:
```bash sudo mkdir -p /etc/ssh/sshd_config.d sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak.$(date +%F)
sudo tee /etc/ssh/sshd_config.d/01-hardening.conf >/dev/null <<'CONF' Protocol 2 PubkeyAuthentication yes PasswordAuthentication no KbdInteractiveAuthentication no ChallengeResponseAuthentication no PermitRootLogin no MaxAuthTries 3 LoginGraceTime 30 ClientAliveInterval 300 ClientAliveCountMax 2 Port 22
AllowUsers # opcional
CONF
sudo sshd -t sudo systemctl reload ssh || sudo systemctl reload sshd