Best lists

Best Self-Hosted 2FA Tools in 2026 (8 Free Picks)

Self-hosted 2FA keeps your second factor on your own server. Here are 8 free open-source tools, from light SSO gateways to full identity providers.

Cysoro Security TeamPublished · 9 min read
2FA1 2TOTP • KeysPasskeysFree • Open source • Yours BEST LISTS Self-hosted2FA tools Your server. Your second factor.
Quick answer

Self-hosted 2FA means running the server that checks your second factor on your own hardware. The best options are Authentik for a full identity provider, Authelia for light SSO and 2FA, Keycloak for enterprise identity, and privacyIDEA for VPN and Linux logins. Every tool here is free to self-host, but you own patching, backups and recovery.

Key takeaways

  • Authentik and Authelia are the best starting points for most homelabs and small teams.
  • Keycloak fits large enterprises, while privacyIDEA is the specialist for VPN and Linux logins.
  • Every tool here is free to self-host, but you must patch it, back it up and test recovery.

Self-hosted 2FA keeps your second factor on your own server, so no cloud vendor holds your login secrets. It suits homelabs, small teams and privacy-minded organisations, but you own the patching, backups and recovery. Choose the right shape first, then the product.

What is self-hosted 2FA?

Self-hosted 2FA means you run the server that checks the second factor yourself, on your own hardware or virtual machine. Instead of a cloud service issuing codes, your server verifies TOTP codes, security keys or passkeys before it lets a user in.

The main reason to self-host is control: your user data, tokens and logs stay on infrastructure you manage, and the service keeps working if a vendor changes its pricing or shuts down. The trade-off is responsibility.

An unpatched identity server is an open front door, so you must update it, back it up and test recovery. The Authelia vs Authentik vs Keycloak comparison puts it plainly: most homelabs land on Authelia or Authentik, while Keycloak is for larger estates.

Which option should you shortlist first?

The table below gives you a fast shortlist. Read the full entries after it for the trade-offs, because the cheapest option is rarely the right one for your risk.

ProductBest forFree to self-hostStarting priceKey strength
AuthentikFull self-hosted IdPYesFree; Enterprise from $5/user/monthBroad protocols, friendly UI
AutheliaLight SSO and 2FAYesFreeTiny footprint
KeycloakEnterprise identityYesFreeWidest federation
privacyIDEAOTP token serverYesFreeCentral token management
ZitadelMulti-tenant SaaSYesFree; Cloud Pro from $100/monthOrganisations built in
Ory KratosAPI-first developersYesFreeHeadless APIs
RauthyMinimal serverYesFreeSmall and fast
2FAuthPersonal TOTP managerYesFreeYour codes, your server
Self-hosted 2FA in three layers1Identityusers in LDAPor the IdP22FA serverTOTP, WebAuthnor passkeys3AppsSSO, proxyor RADIUS
Self-hosted 2FA has three layers: who you are, the second factor, and the apps it protects. Illustration by Cysoro.

How did we choose these options?

We shortlisted open-source projects that are actively maintained, can be self-hosted today, and cover a real 2FA use case: a full identity provider, a light SSO gateway, a dedicated token server, or a personal TOTP manager. We used each project's documentation and pricing pages, as reported in recent comparisons, and we did not invent test scores or user counts.

1. Authentik — best for teams that want a full self-hosted identity provider

Authentik is a self-hosted identity provider with single sign-on, MFA and flexible login flows. It supports TOTP, WebAuthn and passkeys, plus OIDC, SAML, LDAP, RADIUS and a proxy provider for apps with no login of their own.

  • OIDC, SAML, LDAP, RADIUS and SCIM
  • TOTP, WebAuthn, passkeys, Duo and SMS factors
  • Visual login flows in the admin UI
  • Proxy provider for apps without login

Pros: Broad protocol coverage in one product, a modern admin UI, and a free open-source edition with no user limit. It can replace a cloud identity provider for internal apps.

Cons: It needs PostgreSQL and regular patching, and the setup is heavier than a simple TOTP server. Some enterprise features need a paid licence.

Pricing: Free for the open-source edition. Authentik Enterprise is from $5 per internal user per month, billed annually, as of November 2026.

Pick Authentik if you want one self-hosted identity provider for SSO and 2FA across many apps, with a friendly admin UI.

2. Authelia — best for homelabs and small teams that want light SSO and 2FA

Authelia is a lightweight open-source authentication server that sits in front of your web apps through a reverse proxy. It adds a login and a second factor before requests reach the app, which makes it ideal for securing self-hosted services.

  • ForwardAuth for NGINX, Traefik and Caddy
  • TOTP, WebAuthn and Duo second factors
  • Single sign-on with one login
  • YAML configuration in Git

Pros: Very light on resources, simple to run, and free under the Apache 2.0 licence. Configuration as code suits teams that manage infrastructure in Git.

Cons: It has no built-in user registration and keeps no users of its own, so you need LDAP or a file-based user store. It is not a full identity platform.

Pricing: Free and open source. There is no paid edition published by the project, so your only cost is hosting.

Pick Authelia if you want the lightest way to add SSO and 2FA in front of self-hosted web apps behind a reverse proxy.

3. Keycloak — best for enterprises that need a full open-source identity server

Keycloak is a widely used open-source identity and access management server. It provides single sign-on, user federation, TOTP and WebAuthn, and fine-grained authorisation, and it is backed by Red Hat.

  • OIDC, SAML and social login
  • TOTP, HOTP, WebAuthn and passkeys
  • User federation with LDAP and Active Directory
  • Realms, roles and step-up authentication

Pros: The broadest protocol and federation coverage of any open-source option, with a large community and long track record. It scales to large user bases.

Cons: It is a Java application with a larger footprint and a steeper learning curve than Authelia or Authentik. Small homelabs will find it heavy.

Pricing: Free and open source under the Apache 2.0 licence. Commercial support is available through the Red Hat build of Keycloak.

Pick Keycloak if you need enterprise-grade SSO and federation, or you already run Java and Red Hat infrastructure.

4. privacyIDEA — best for teams that need a dedicated OTP token server

PrivacyIDEA is an open-source multi-factor authentication server focused on managing tokens. It adds a second factor to VPNs, Linux logins and web apps through RADIUS, PAM and a REST API, without replacing your identity provider.

  • TOTP, HOTP, hardware and software tokens
  • WebAuthn, SMS, email and paper tokens
  • RADIUS, PAM and REST API integration
  • Token lifecycle and audit logs

Pros: A specialist tool that does one job well: central, auditable token management for systems you already run. It fits VPN and Linux login use cases neatly.

Cons: It is not a full identity provider, so you still need a directory and a login flow. The admin UI is functional rather than polished.

Pricing: Free and open source. Paid support and enterprise features are available from the vendor; check its site for current support pricing.

Pick privacyIDEA if you need a central token server for VPN, SSH and Linux logins, rather than a whole new identity platform.

5. Zitadel — best for multi-tenant apps and SaaS teams

Zitadel is an open-source identity platform built around organisations, which makes it a natural fit for software that serves many customer companies. It supports passkeys, TOTP and OIDC, and it can be self-hosted or used as a managed cloud.

  • Organisations and multi-tenancy built in
  • Passkeys, TOTP and OIDC
  • Self-hosted or managed cloud
  • APIs and SDKs for developers

Pros: Multi-tenancy is a first-class feature, not an add-on. The cloud option lets you start without running servers, while self-hosting stays free.

Cons: Self-hosting needs more setup than a simple TOTP server, and the AGPL licence matters if you modify and distribute the code.

Pricing: Free to self-host. Zitadel Cloud has a free tier, and Cloud Pro is from $100 per month as of November 2026.

Pick Zitadel if you build software for many customer organisations and need tenant-aware login and MFA.

6. Ory Kratos — best for developers who want headless, API-first identity

Ory Kratos is the headless identity and user-management component of the Ory stack. It provides login, registration, MFA and recovery through APIs, so you build your own login screens on top of it.

  • WebAuthn, TOTP and lookup secrets
  • Headless API-first design
  • Works with Ory Hydra for OAuth2 and OIDC
  • Self-hosted or Ory Network cloud

Pros: Clean APIs and full control over the login experience. It suits teams that want identity as a building block, not a ready-made admin UI.

Cons: You must build your own user interface, which adds development work. It is not the fastest choice for a homelab that wants a ready portal.

Pricing: Free and open source under the Apache 2.0 licence. Ory Network offers a free development tier, with paid production plans.

Pick Ory Kratos if you are a developer building a custom login experience and you want identity handled by APIs.

7. Rauthy — best for small teams that want a tiny, fast identity server

Rauthy is a lightweight open-source identity provider written in Rust. It provides OIDC, passkeys and TOTP with a small footprint, which suits a single server or a small virtual machine.

  • OIDC with passkeys and TOTP
  • Small resource footprint
  • Simple admin interface
  • Self-hosted with Docker

Pros: Very light and fast, with fewer moving parts than the big identity platforms. It is easy to keep updated on a small server.

Cons: It is a smaller project with a narrower feature set than Keycloak or Authentik, so check that it covers your protocols before committing.

Pricing: Free and open source. Your only cost is hosting.

Pick Rauthy if you want a minimal, fast self-hosted identity server and you do not need the full feature set of the larger platforms.

8. 2FAuth — best for individuals who want a self-hosted TOTP manager

2FAuth is a self-hosted web application for managing your own TOTP accounts. It stores your two-factor codes in one place you control, with groups, icons and a clean interface, instead of keeping them only on one phone.

  • TOTP code generation and management
  • Groups and search for many accounts
  • Import from other authenticator apps
  • Self-hosted with Docker

Pros: You control your own second-factor data, and you can reach your codes from any browser. It is simple to install and easy to back up.

Cons: It manages your codes; it does not add 2FA to a server or app by itself. You must still protect the 2FAuth install itself with a strong password and HTTPS.

Pricing: Free and open source. Your only cost is hosting.

Pick 2FAuth if you want a self-hosted home for your own TOTP codes, rather than a server that enforces 2FA for other people.

How do you choose the right option?

First decide what shape you need. If you want one login for many web apps, pick a full identity provider such as Authentik or Keycloak. If you only need to gate existing apps, Authelia is lighter. If you need to add MFA to a VPN or Linux login, privacyIDEA is the specialist. Check protocol support, backup options and how often the project ships security fixes before you commit.

Also check your own capacity. Self-hosting means you patch, monitor and recover the server. If nobody on your team will own that job, a managed service is safer. For a wider view of account protection, see our best account takeover protection guide.

What is the difference between free and paid options?

Every product in this list is free to self-host under an open-source licence, so the software cost is zero. You still pay for hosting, your time, and backups. Paid tiers add directory sync, audit logs, support and enterprise features. Authentik Enterprise, for example, is from $5 per internal user per month, while Zitadel Cloud Pro is from $100 per month.

Do not confuse free software with free security. A free server that is never patched is less safe than a paid cloud service that is. Budget time for updates, and keep an encrypted backup of the server data and your recovery codes. You can generate strong secrets for your setup with our free password generator.

Before you self-host 2FA, check these five things1Backupsencrypted,off-server2Updatespatch theIdP fast3HTTPSvalid cert,no plain HTTP4Recoverycodes storedoffline5Testlockout drillbefore go-live
Five checks before you trust a self-hosted 2FA server with your logins. Illustration by Cysoro.

What should you do next?

Install your chosen server in a test environment first, add one low-risk app, and complete a full lockout drill: lose access, recover with your backup codes, and restore from backup. Only then move real users across, and turn on HTTPS with a valid certificate from day one.

Before you expose the server, review the basics in our guide to securing your Wi-Fi. The open-source identity comparisons at Start With Identity also explain how Keycloak, Authelia and privacyIDEA differ.

The bottom line

Self-hosted 2FA gives you control, but it only helps if you maintain it. For most homelabs, Authelia or Authentik is the right start; for enterprises, Keycloak or Authentik fits better; for VPN and Linux logins, privacyIDEA is the specialist.

Whichever you pick, keep it patched, back it up, and store recovery codes offline. A second factor you cannot recover from is a lockout waiting to happen, not security.

Frequently asked questions

What is self-hosted 2FA?

Self-hosted 2FA means you run the server that verifies the second factor yourself, instead of using a cloud service. Your server checks TOTP codes, security keys or passkeys before letting a user into an app or system.

Is self-hosted 2FA safer than cloud 2FA?

It can be, because your data stays on your own infrastructure and you control the logs and backups. It is only safer if you keep the server patched and backed up. An unpatched self-hosted server is less safe than a maintained cloud service.

What is the best self-hosted 2FA for a homelab?

Authelia is the lightest choice for gating web apps behind a reverse proxy, while Authentik is the best all-round choice if you want a friendly admin UI and broad protocol support. Most homelabs land on one of those two.

Can I use self-hosted 2FA with my VPN?

Yes. Tools such as privacyIDEA add a second factor to VPNs and Linux logins through RADIUS or PAM. Full identity providers such as Keycloak and Authentik can also protect VPNs that support OIDC or SAML.

Do I need a security key for self-hosted 2FA?

No, TOTP codes from an authenticator app work with all the tools in this list. Security keys and passkeys are stronger, because they cannot be phished, so use them for admin accounts where you can.

What happens if I lose access to my self-hosted 2FA server?

That is why backups and recovery codes matter. Keep an encrypted backup of the server data, store recovery codes offline, and test a full restore before you move real users across. Without a backup, you may be locked out of every app it protects.

Is Authentik really free?

Yes, the open-source edition of Authentik is free under the MIT licence, with no user limit. Enterprise features such as directory sync and audit logs need a paid licence, from $5 per internal user per month.

Sources

  1. Authentik vs Authelia vs Keycloak — Big Iron
  2. Top 6 Open-Source MFA and Passwordless Tools — Start With Identity
  3. Top 5 Open-Source IAM Solutions in 2026 — Compile7
  4. CISA, NSA, FBI, MS-ISAC — Phishing Guidance: Stopping the Attack Cycle at Phase One
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against project documentation and pricing pages as reported in recent open-source IAM comparisons, plus CISA phishing guidance.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free