Lion Cipher Lab

Add two-factor authentication (TOTP) to SSH

Why it matters

A single secret is a single point of failure. If someone steals your SSH private key off a backed-up laptop, phishes your password, or finds it in a leaked repo, that one secret is the whole door — and they walk in as you. Two-factor authentication fixes this by demanding something else as well: after your key or password, the server also asks for a short code that only your authenticator app can produce right now. An attacker who has your key but not your phone is stopped cold at the second prompt. This is the same defense your bank and email already use, applied to the most attacked…

What you'll learn

Steps in this lab

  1. What 2FA and TOTP mean, and why put them on SSH
  2. Read this first: do not lock yourself out
  3. Install the Google Authenticator PAM module
  4. Create your secret: run the setup, scan the QR, and SAVE the backup codes
  5. Wire the module into SSH's PAM stack
  6. Tell sshd to demand key AND code — sshd_config
  7. Validate, restart, and TEST from a SECOND session
  8. What you gained — and where 2FA still ends

Open the full interactive lab →