Prerequisites
- A GitHub account (the example below uses an account named
alice-admin-kk). - An authenticator app or extension that supports TOTP (Time-Based One-Time Passwords) such as 1Password, Microsoft Authenticator, Google Authenticator, Authy, Proton, or the GitHub Mobile app.
- A secure place to store recovery codes (password manager, encrypted vault, or offline secure storage).
1 — Open account sign-in settings
Sign in to the account you want to secure. Open your account settings and navigate to the “Password and authentication” or “Sign in methods” section to view current sign-in options and whether 2FA is enabled.
2 — Choose a second-factor method
If 2FA is not yet enabled, start the setup flow. GitHub supports several second-factor methods:SMS-based 2FA is less secure (subject to SIM swapping and interception). Prefer TOTP authenticators or hardware/WebAuthn methods where possible.
3 — Set up a TOTP authenticator
When setting up a TOTP authenticator, GitHub will display a QR code and a setup key. Use your authenticator app or browser extension to add the account. If the authenticator cannot scan the QR code (e.g., a browser extension without camera access), copy the setup key and add it manually.
- Open your authenticator app/extension and create a new account entry.
- Scan the QR code or paste the setup key provided by GitHub.
- Your authenticator will show a 6-digit TOTP code that rotates every 30 seconds.
- Enter the current code into GitHub to verify and continue.
4 — Save recovery codes
After verifying your authenticator, GitHub generates recovery codes. These are one-time-use codes that let you access your account if you lose your authenticator.Store recovery codes somewhere safe (for example, a secure password manager or an encrypted file). Treat them like backup credentials.

5 — Confirm the sign-in flow
To confirm everything works, sign out and sign back in. After entering your username and password, GitHub will prompt for a second-factor code. Provide:- The TOTP code from your authenticator, or
- One of your saved recovery codes if you cannot access the authenticator.
6 — Enterprise and organization considerations
At the enterprise or organization level, you can invite members and consider enforcing 2FA across the organization.- Use the enterprise “People” or “Invitations” tabs to invite owners and members.
- To enforce 2FA for an organization or enterprise, review GitHub’s documentation on enforcing two-factor authentication for your enterprise.
Resources and further reading
- GitHub Docs — Two-factor authentication (2FA)
- WebAuthn / Passkeys overview
- Best practices for storing recovery codes