SSH Hardening
Cheat sheet · https://pcornel.dk/topic.php?topic=2846
Answer
SSH hardening reduces the risk of the SSH service: key-only authentication, no root password login, allowed users/groups, modern algorithms, rate limiting and restricting the source networks.
Remember
Set PasswordAuthentication no, PermitRootLogin prohibit-password (or no), AllowGroups, and keep algorithms current. Combine with a firewall source restriction and fail2ban. Validate with sshd -t and test with a second session.
First checks
sestatus / aa-status— SELinux or AppArmor statess -tulpn— listening servicesjournalctl -u sshd -g 'Failed'— failed loginsausearch -m avc,user_login -ts today— audit events (auditd)
Verify in this order
connection allowed by firewall → modern key exchange → only allowed users → key authentication → logged
Where it usually breaks
First mismatch in identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2846