Set up 2FA on GitHub
Turn on GitHub 2FA under Settings › Password and authentication › Enable two-factor authentication, and choose an authenticator app. It takes about three minutes; GitHub requires 2FA for anyone who contributes code.
- Time
- About 3 minutes
- Where
- GitHub website
- Setting
- “Authenticator app”
Path: GitHub › Settings › Password and authentication › Two-factor authentication
Before you start
- Your GitHub password (and sudo mode: GitHub may ask you to re-enter it).
- A computer with github.com open.
- Somewhere to save the recovery codes file, such as a password manager.
Turn on 2FA for GitHub, step by step
- 1
Open Password and authentication
On github.com click your avatar › Settings, then Password and authentication in the left sidebar.
- 2
Enable two-factor authentication
Click “Enable two-factor authentication”. GitHub shows a QR code; the “setup key” link reveals the text key.
- 3
Scan it with 2FA Setup
Tap Scan below and point the camera at the QR code. Type the 6-digit code from 2FA Setup into the “Verify the code from the app” field.
How scanning works - 4
Download recovery codes
GitHub shows 16 recovery codes. Click Download, store the file off your phone, then click “I have saved my recovery codes” to finish.
Scan the GitHub QR code with 2FA Setup
Open 2FA Setup and tap +. The camera opens straight away: point it at the QR code GitHub shows. If you are setting up on the same iPhone, take a screenshot and choose From Photos, or copy the text key and choose Enter key. Spaces and lowercase letters in the key are fine.
2FA Setup reads the algorithm, digit count and period from the QR code, shows “GitHub is protected” and your first code. Enter that code on GitHub to finish. Your secret is stored in the iPhone Keychain and never leaves the device.
Free for up to 5 accounts. Pro is $49.99 once for life, or a plan.
Other 2FA options on GitHub
GitHub supports authenticator apps (TOTP), passkeys, security keys, GitHub Mobile, and SMS in some countries. You can register several at once; an authenticator app plus a passkey is a good pair.
Where the codes are, and your backup codes
Your code appears in 2FA Setup as “GitHub” with your username. It changes every 30 seconds.
GitHub recovery codes are 16 one-time codes in the format xxxxx-xxxxx (the file is github-recovery-codes.txt). Regenerating them cancels the old set.
Without codes or a second method, GitHub can start account recovery if you have a verified device, an SSH key or a personal access token. It takes 1–3 business days.
Why the codes work without internet
When you scan the QR code, GitHub and your iPhone share a secret key. Every 30 seconds both sides combine that key with the current time and get the same 6-digit number (the TOTP standard, RFC 6238). Nothing is sent between them, which is why codes work in airplane mode and why the clock matters: if your iPhone time is off, the numbers no longer match. You can watch it happen with our TOTP generator.
GitHub 2FA questions
Is 2FA mandatory on GitHub?
GitHub requires two-factor authentication for accounts that contribute code on github.com. You get an email with a deadline; after it, you must enable 2FA to keep using the account.
Does GitHub 2FA affect git push over HTTPS?
Yes: with 2FA on, you cannot push with your password. Use a personal access token, SSH keys, or a credential helper such as Git Credential Manager.
GitHub says “Two-factor code verification failed”.
Make sure your iPhone sets the time automatically and enter a fresh code before it expires. If you set up 2FA twice, use the newest GitHub entry.
Can I use the same authenticator for GitHub Enterprise or GitLab?
Yes, each is a separate entry. Scan each service’s QR code into 2FA Setup.
Official source: GitHub Docs: Configuring two-factor authentication. Menus change; if a label differs from this guide, tell us at support@2fasetup.app.