SEC.01

The playbook

The run starts read-only: the recon probes decide what happens next. The steps that follow are adapted to the distribution and state found — a real machine is rarely clean.

  1. 01recondistro and OpenSSH version
  2. 02reconeffective SSH config (UsePAM yes required)
  3. 03reconsshd PAM auth stack (common-auth or password-auth) and 2FA already wired?
  4. 04reconPAM module already installed?
  5. 05reconthe user exists, has an authorized key (mandatory) and has already enrolled TOTP?
  6. 06reconaccounts without a key: they will no longer be able to log in (publickey becomes mandatory)
  7. 07reconis sshd_config.d included? existing drop-ins
  8. 08reconSELinux enforcing (RHEL): watch for denials after testing
  9. 09actEnable EPEL (RHEL/Rocky/Alma only)verify
  10. 10actInstall the PAM moduleverify
  11. 11actEnroll TOTP (done by the user)verify
  12. 12actBack up PAM and sshd_configverify
  13. 13actInclude sshd_config.d (only if the Include is missing)verify
  14. 14actRequire key + TOTP in sshddestructiveverify
  15. 15actReload sshd (without dropping sessions)destructiveverify
  16. 16actWire TOTP into the sshd PAM stackdestructiveverify

SEC.02

What it verifies

Each step ships its own check. The run only moves on when the check passes, so what the recipe reports as done is what is actually on the server.

  1. 01Enable EPEL (RHEL/Rocky/Alma only)Verified bydnf repolist enabled | grep -ci epel
  2. 02Install the PAM moduleVerified bycommand -v google-authenticator
  3. 03Enroll TOTP (done by the user)Verified bytest -s "$(getent passwd ${user} | cut -d: -f6)/.google_authenticator" && echo enrolled
  4. 04Back up PAM and sshd_configVerified byls -1 /etc/pam.d/sshd.bak.* /etc/ssh/sshd_config.bak.*
  5. 05Include sshd_config.d (only if the Include is missing)Verified bygrep -cE '^\s*Include\s+/etc/ssh/sshd_config.d/' /etc/ssh/sshd_config && sshd -t && echo ok
  6. 06Require key + TOTP in sshdVerified bysshd -t && sshd -T | grep -Ei '^(authenticationmethods|passwordauthentication) '
  7. 07Reload sshd (without dropping sessions)Verified bysystemctl is-active ssh.service sshd.service ssh.socket 2>/dev/null | grep -c '^active'
  8. 08Wire TOTP into the sshd PAM stackVerified bygrep -cE '^auth\s+required\s+pam_(google_authenticator|permit)\.so' /etc/pam.d/sshd

SEC.03

Guardrails

Non-negotiable instructions the run must respect, whatever it finds on the server.

STOP if the user has no authorized key or if an account used without a key would lose access. Never generate the TOTP secret yourself. Mandatory order: sshd (PasswordAuthentication no) and reload BEFORE PAM. Always sshd -t before reloading; reload, never restart. SELinux enforcing: on failure, check ausearch -m avc and never disable SELinux. Keep the session open and have a NEW connection tested; the Servor agent does not go through SSH, the Servor terminal can restore the backups.

SEC.04

Variables

What you choose before launching — the recipe fills in the rest.

NameMeaning
${user}SSH user to protect

SEC.05

How a recipe runs in Servor

Servor is zero-knowledge: the platform cannot execute anything on its own. When you launch this recipe, a run reads the reconnaissance, plans the steps and asks for your approval. Each approved command is signed by your browser — with a key the server never sees — then relayed verbatim to the agent, which verifies the signature locally before executing.

recipe — fail2ban_setup150+ in catalogue
security4 steps · low risk · idempotentrun
reconsshd present? ufw active? existing jails?✓
actinstall fail2ban · write default jails✓
actenable service · restart sshd (safe)✓
verifytest ban 60s · jails active · sshd alive✓

search by intent — type “firewall”, get ufw

  • 01Read-only reconnaissance before any change
  • 02Every command signed by your browser, approved by you
  • 03Each step verified before the run moves on, every run kept in the history

SEC.06

Deploy on Servor button

Maintain SSH 2FA (TOTP) or a project that needs it? Put this button in your README or on your site: one click and your users install it on their own server.

Deploy on ServorDark background
Deploy on ServorLight background
[![Deploy on Servor](https://servor.app/badges/deploy-on-servor.svg)](https://servor.app/deploy/setup-ssh-2fa)

SEC.07

Verified recipe

Run this recipe on your server

Connect a server, launch the recipe, and approve each step as Servor executes and verifies it. Free plan, no card required.