Setting up a TOTP app
- On GitHub, open Settings, then Password and authentication.
- Choose to enable two-factor authentication and pick the authenticator app option.
- Scan the QR code (or enter the setup key) in your app and type the current code back into GitHub.
Keep the QR code and key out of screenshots, issues and commits. Anyone with that key can produce your codes.
Recovery codes and a second method
During setup GitHub shows recovery codes and lets you download them. Each one works once. Store them outside the phone that holds your authenticator, for example in a password manager.
GitHub recommends adding more than one method. A passkey or a security key is a good second option, so losing a phone doesn’t lock you out.
2FA codes are not Git passwords
The six-digit code is for signing in to github.com. It does not replace the credentials used by git push, the API or CI jobs. Over HTTPS, use a personal access token or a credential manager; over SSH, your SSH key. Give tokens only the scopes they need.
When a code is rejected or the phone is gone
- Make sure the entry is for the right GitHub account and the phone clock is set automatically.
- After reconfiguring 2FA, codes from the previous entry no longer match.
- No app? Use a recovery code, a passkey or a security key you added earlier.
Without any of these, GitHub has a recovery process that checks other evidence, such as a verified device or SSH key. It can take time and is not guaranteed. If you kept the original setup key, our TOTP code generator can show the current code locally.