On this page
GitHub requires two-factor authentication for many accounts that contribute code, and a TOTP authenticator is the most common way to satisfy it. During setup, GitHub shows a QR code with a setup key link beneath it. Paste that setup key above and you get the same 6-digit code an authenticator app would show.
Developers often work on several machines, and having a quick browser-based code can help when your phone is not within reach. The key is processed only in your browser; nothing is sent to a server. Treat the key like a credential: back it up in a password manager or authenticator, and keep GitHub's recovery codes somewhere you can reach without your phone.
How to find your GitHub secret key
- On GitHub, click your avatar → Settings → Password and authentication.
- Under Two-factor authentication, select Enable two-factor authentication (or Edit next to Authenticator app if 2FA is already on).
- When the QR code appears, click the setup key link to reveal the text key.
- Copy the setup key and save it privately. The page layout may shift slightly as GitHub updates its settings.
How to log in to GitHub with the code
- Paste the GitHub setup key into the generator at the top of this page.
- Copy the 6-digit code and enter it in the verification field on GitHub.
- Download your recovery codes when GitHub offers them, then finish setup. Use this page whenever GitHub asks for an authentication code later.
GitHub 2FA tips
- Download and store GitHub's recovery codes in a safe place. GitHub Support often cannot restore access to a 2FA account without them or another configured method.
- Once 2FA is on, git over HTTPS needs a personal access token instead of your password; SSH keys keep working as before.
- Add a second method, such as a passkey or security key, so that losing one factor never locks you out of your repositories.
Your GitHub key is processed only in this browser and is never uploaded. Keep a copy in an authenticator app or password manager as well.
GitHub 2FA FAQ
Why does GitHub require 2FA?
GitHub has made two-factor authentication mandatory for many accounts that contribute code, to protect the software supply chain. If you received a notice, you have a deadline to enable 2FA, and an authenticator app with this generator meets the requirement.
Can I use this generator with the GitHub CLI?
The GitHub CLI usually authenticates through a browser flow or token. If it opens a browser login that asks for a 2FA code, generate it here. For git commands over HTTPS, use a personal access token rather than a 2FA code.
I lost my GitHub 2FA device. How do I get back in?
Paste your saved setup key into this page or use one of your recovery codes. GitHub may also accept other configured methods, like a passkey. Without any of these, regaining access can be very difficult.
Is my GitHub setup key safe here?
Yes, the code is calculated in your browser and the key is never uploaded. Still, avoid pasting it on shared or untrusted machines, and never commit it to a repository.