Skip to content

Enable TOTP for the local admin

Require a time-based one-time password after the local admin's password.

RFC 6238: SHA-1, 6 digits, 30-second step. It is off unless a secret is configured, and it applies to the local account only: SSO logins keep whatever MFA the identity provider enforces.

Prerequisites

  • A working local admin (GPM_LOCAL_ADMIN_USER plus a bcrypt hash).
  • An authenticator app (any RFC 6238 client).
  • A writable secret file under an allowlisted GPM_SECRET_FILE_ROOTS root.

Steps

  1. Generate a secret. The base32 secret goes to stdout, the enrolment URI to stderr:

img=ghcr.io/rake-pro/go-proxy-manager sudo install -m 0400 -o "$(docker run --rm --entrypoint id "$img" -u)" \ -g "$(docker run --rm --entrypoint id "$img" -g)" /dev/null ./admin_totp docker run --rm "$img" totp-secret -account admin -issuer gpm | sudo tee ./admin_totp >/dev/null

The file is created owner-only for the image's gpm user first, see Secret files.

  1. Add it to the authenticator app. Either type the base32 secret in by hand, or render the printed otpauth://totp/... URI as a QR code with any QR tool and scan it. gpm ships no QR renderer.
  2. Mount the file as a secret and point gpm at it:

yaml environment: GPM_LOCAL_ADMIN_TOTP_SECRET_FILE: /run/secrets/gpm_admin_totp secrets: - gpm_admin_totp

The inline form GPM_LOCAL_ADMIN_TOTP_SECRET also works. Both are read once at startup, exactly like the password hash; neither is ever written to the git-backed config, and neither can be resolved by a ${ENV:...} reference. 4. Restart the container. The startup log prints local admin TOTP is enabled. A secret that is not usable base32 is fatal: gpm refuses to start rather than silently dropping the second factor. A _FILE that is set but cannot be read (missing mount, mode too strict for the non-root user), or that holds only whitespace (a secret created from an empty value), is not fatal, because the same process serves the proxy: gpm logs an error and refuses every local admin login until the file is readable and the container is restarted. 5. Sign in. The password form now leads to a second page asking for the 6-digit code.

Verify

Check Expected
GET /api/capabilities adminLogin.totp: true
GET /api/runtime localAdminTOTP: true
Startup log local admin TOTP is enabled
Login Password page, then a "Verification code" page, then the panel

Troubleshooting

Symptom Cause Fix
Every code is rejected Server and phone clocks differ by more than 30 seconds; only one step either side is accepted Fix time sync (NTP) on the host
Every code is rejected, and the log says the secret is not usable base32 gpm refuses to start with an unparseable secret, so this is a stale container Regenerate with gpm totp-secret and restart
Password is always refused, and the log says the local admin TOTP secret is unreadable or empty GPM_LOCAL_ADMIN_TOTP_SECRET_FILE points at a file the gpm user cannot read, or at an empty file; local login is refused rather than falling back to the password alone Fix the mount, the file mode or the file content and restart
"Wrong code." on a code that just worked Codes are single-use: the accepted step cannot be replayed Wait for the next 30-second step
"Too many attempts. Try again in N minutes." (HTTP 429) Five failed attempts (wrong password or wrong code) from one client IP, or twenty against one username from any clients, within 15 minutes Wait the minutes shown, or restart gpm: the lockout and the used-code ledger are in memory only
Locked out with no authenticator (phone lost) The secret is the only enrolment Unset GPM_LOCAL_ADMIN_TOTP_SECRET* and restart to sign in with the password alone, then enrol a new secret