With two-factor authentication enabled, you'll need to provide an authentication code when accessing GitHub through your browser. If you access GitHub using other methods, such as the API or the command line, you'll need to use an alternative form of authentication. For more information, see "About authentication to GitHub."
After you sign in to GitHub using your password, you'll be prompted to provide an authentication code from a text message or your TOTP app.
GitHub will only ask you to provide your 2FA authentication code again if you've logged out, are using a new device, or your session expires.
If you chose to set up two-factor authentication using a TOTP application on your smartphone, you can generate an authentication code for GitHub at any time. In most cases, just launching the application will generate a new code. You should refer to your application's documentation for specific instructions.
If you delete the mobile application after configuring two-factor authentication, you'll need to provide your recovery code to get access to your account. For more information, see "Recovering your account if you lose your two-factor authentication credentials"
If you set up two-factor authentication via text messages, GitHub will send you a text message with your authentication code.
If you have installed and signed in to GitHub Mobile, you may choose to authenticate with GitHub Mobile for two-factor authentication.
Sign in to GitHub with your browser, using your username and password.
If you have added a security key to your account, you'll first be prompted to insert and use a security key. To skip using a security key, click Authenticate with GitHub Mobile.
GitHub will send you a push notification to verify your sign in attempt. Opening the push notification or opening the GitHub Mobile app will display a prompt, asking you to approve or reject this sign in attempt.
Note: This prompt may require you to enter a two-digit number displayed within the browser you are signing in to.
- Upon approving the login attempt using GitHub Mobile, your browser will complete the sign in attempt automatically.
- Rejecting the sign in attempt will prevent the authentication from finishing. For more information, see "Keeping your account and data secure."
After you've enabled 2FA, you will no longer use your password to access GitHub on the command line. Instead, use Git Credential Manager, a personal access token, or an SSH key.
Setup instructions vary based on your computer's operating system. For more information, see Download and install in the GitCredentialManager/git-credential-manager repository.
After you've enabled 2FA, you must create a personal access token to use as a password when authenticating to GitHub on the command line using HTTPS URLs.
When prompted for a username and password on the command line, use your GitHub username and personal access token. The command line prompt won't specify that you should enter your personal access token when it asks for your password.
For more information, see "Creating a personal access token."
Enabling 2FA doesn't change how you authenticate to GitHub on the command line using SSH URLs. For more information about setting up and using an SSH key, see "Connecting to GitHub with SSH."
When you access a repository via Subversion, you must provide a personal access token instead of entering your password. For more information, see "Creating a personal access token."
If you lose access to your two-factor authentication credentials, you can use your recovery codes or another recovery method (if you've set one up) to regain access to your account. For more information, see "Recovering your account if you lose your 2FA credentials."
If your authentication fails several times, you may wish to synchronize your phone's clock with your mobile provider. Often, this involves checking the "Set automatically" option on your phone's clock, rather than providing your own time zone.