Two-factor authentication, or 2FA, is a way of logging into websites that requires more than just a password. Using a password to log into a website is susceptible to security threats, because it represents a single piece of information a malicious person needs to acquire. The added security that 2FA provides is requiring additional information to sign in.

In GitHub's case, this additional information is an authentication code delivered to your cell phone that's generated by an application on your smartphone or sent as a text message (SMS). After 2FA is enabled, GitHub generates an authentication code that is sent to your phone any time someone attempts to sign into your GitHub account. The only way someone can sign into your account is if they know both your password and an authentication code from your phoneor a physical security key device.

We strongly urge you to turn on 2FA for the safety of your account, not only on GitHub, but on other websites that support it. You can use 2FA to access GitHub via:

  • The GitHub website
  • The GitHub API
  • GitHub Desktop

Warning: For security reasons, GitHub Support cannot restore access to accounts with two-factor authentication enabled if you lose your phone and don't have access to your recovery codes.

Configuring authentication via a TOTP mobile app

We recommend authenticating with a Time-based One-Time Password (TOTP) application, which automatically generates an authentication code that changes after a certain period of time. TOTP applications are more reliable than SMS, especially for locations outside the US. For more information, see Configuring two-factor authentication via a TOTP mobile app.

Configuring authentication via text message

If you're unable to authenticate using a TOTP mobile app or security key, you may be able to generate codes using SMS. This method isn't recommended for non-US numbers; before configuring authentication via SMS, review our list of countries where GitHub supports authentication via SMS. For more information, see Configuring two-factor authentication via text message.

Configuring authentication via FIDO U2F

Note: FIDO U2F authentication is currently only available for the Chrome browser.

GitHub supports the FIDO U2F open standard, which uses a physical device to generate an authentication code. For more information, see Configuring two-factor authentication via FIDO U2F.

Saving your recovery codes

After successfully setting up 2FA, you'll be provided a set of randomly generated recovery codes that you should view and save. We strongly recommend saving your recovery codes immediately. If you don't, though, you can download them at any point after enabling two-factor authentication. For more information, see Downloading your two-factor authentication recovery codes.

Specifying a fallback SMS number

You can provide a second number for a fallback device. If you lose access to both your primary device and your recovery codes, a backup SMS number can get you back in to your account.

Changing authentication delivery methods

You can always switch between receiving authentication codes through a text message or a mobile application.