2FAuth

stack Security

Web app for your two-factor authentication codes, a self-hosted stand-in for Google Authenticator: add accounts by scanning or uploading their QR codes, then copy codes from any browser.

Install 2FAuth

It isn't in the main Portainer Templates list yet, so use this one. Portainer takes one URL at a time, so it swaps out whatever list you had before.

In Portainer, head to Settings --> App Templates, paste this in as the URL and save.

https://raw.githubusercontent.com/NotAFlightRisk/portainer-templates-extras/main/templates.json
  1. Open App Templates and pick 2FAuth.
  2. Fill in App key. Everything else can stay as it is.
  3. Hit Deploy the stack, then open http://<your-server>:8200 in a browser.

Before you start

Set the app key before you deploy (exactly 32 characters, openssl rand -hex 16 makes one), since the stack won't start without it. Keep it the same from then on, as it signs logins and encrypts your codes if you turn on encryption. Then open http://<your-host>:8200 (or whichever port you picked) and register: the first account becomes the admin. Anyone who can reach it can register after that, so once you're in, tick Disable registration under Admin panel --> Authentication (the menu under your email). Scanning a QR code with the camera and passkeys both need HTTPS, so behind plain http you'll be uploading QR screenshots and signing in with a password. Everything lives in the 2fauth-data volume, and since that's every 2FA secret you've got, back it up. Docs: docs.2fauth.app

Settings

What the Portainer form asks for. With compose they go in the .env file instead.

VariableWhat it's forDefault
TWOFAUTH_APP_KEYApp key (required) Exactly 32 characters. Generate one with: openssl rand -hex 16. Keep it the same when you redeploy. Needs filling in
TWOFAUTH_PORTHost port for the web UI 8200

Services

The containers this stack runs, with ports as they come out of the box.

ServiceImagePorts
2fauth2fauth/2fauth:88200:8000

More apps