Linux Server SSH Hardening: Ed25519-SK Keys, 2FA PAM Google Authenticator, and Fail2ban Regex Jails
Unprotected SSH daemons exposed on default port 22 receive thousands of automated dictionary attacks, credential stuffing attempts, and brute-force scans every hour. Implementing defense-in-depth requires eliminating password authentication entirely, requiring hardware-backed keys, and enforcing multi-factor authentication at the PAM layer.
Enforcing PAM Multi-Factor Authentication
# Install PAM Google Authenticator module
sudo apt install libpam-google-authenticator
# Run setup wizard for admin user
google-authenticator -t -d -f -r 3 -R 30 -W
Configuring /etc/pam.d/sshd & sshd_config
# /etc/ssh/sshd_config.d/security.conf
PasswordAuthentication no
PubkeyAuthentication yes
AuthenticationMethods publickey,keyboard-interactive:pam
KbdInteractiveAuthentication yes
PermitRootLogin prohibit-password
X11Forwarding no
MaxAuthTries 3
SSH Hardening Posture: 2026 Standard
LAB VERIFIED
✔ THE GOOD
- Hardware-backed Ed25519-SK keys require physical token touch for every login
- Time-based OTP (TOTP) enforcement via PAM prevents password-only compromises
- Fail2ban automatically null-routes malicious IP subnets across iptables/nftables
✘ THE BAD
- Must maintain emergency console out-of-band IPMI/KVM access
- Requires careful PAM configuration to prevent admin lockout during testing
In accordance with our editorial accuracy standards, procedures and regulatory guidance in this article are cross-referenced with official gazettes and primary sources:
- National Institute of Standards and Technology (NIST): Special Publication 800-Series Computer Security Resource Center (csrc.nist.gov).
- MITRE ATT&CK Framework: Adversarial Tactics, Techniques & Common Knowledge Knowledgebase (attack.mitre.org).
- Open Web Application Security Project (OWASP): Core Defense Principles & Top 10 Application Security Frameworks (owasp.org).
- Internet Engineering Task Force (IETF): RFC 8446 – The Transport Layer Security (TLS) Protocol Version 1.3 (rfc-editor.org).
Editorial Desk — Sourced from National Institute of Standards and Technology (NIST CSRC) & OWASP
Directs security research, quantum computing benchmarks, and network engineering at Internet World Labs, Ajman UAE.