How do you enforce MFA for SSH?
AdvancedProductionSSH & Access Hardening
Answer
Options: FIDO2 hardware-backed keys (ssh-keygen -t ed25519-sk), where the key requires a physical touch; or PAM with TOTP (pam_google_authenticator) combined with keys:
AuthenticationMethods publickey,keyboard-interactive
KbdInteractiveAuthentication yes
UsePAM yes
and auth required pam_google_authenticator.so in /etc/pam.d/sshd. At scale we prefer an access proxy (Teleport, SSM, Boundary) that does SSO + MFA centrally and issues short-lived certs.
More on SSH & Access Hardening
What are the first sshd_config changes you make on a new production server?BeginnerWhy use a drop-in file in /etc/ssh/sshd_config.d/ instead of editing sshd_config?IntermediateWhy disable SSH password authentication entirely?BeginnerShould you change the SSH port from 22?IntermediateWhat are SSH certificates and why do large fleets use them?AdvancedHow do you restrict what a specific SSH key can do?Advanced