How to Enable 2FA for your GitHub Account 
Tags: beginners, tutorial, github, security
Published: 2023-02-27 22:31:21

Two-factor authentication (2FA) is an extra layer of security used when logging into websites or apps. It requires you to log in with your username, password, and provide an additional form of authentication that is uniquely accessed by you. 
![2FA will be required by end of 2023](https://user-images.githubusercontent.com/47188731/221370573-4b27d981-52f1-48d1-8c54-9834253a1d38.png)

**By the end of 2023, 2FA will be mandatory for all GitHub accounts - both on web and mobile (iOS and Android).** Let’s get a head start on the process by enabling at least 1 form of 2FA on our GitHub accounts.

In your account, you have the option to choose one of the following methods for 2FA:
- Authenticator App (TOTP app) 
- Text/SMS Authentication 
- GitHub Mobile App
- Security Codes

I strongly recommend using an authenticator app, such as Microsoft Authenticator or Authy, to configure 2FA for your account as they are more reliable that SMS/text message based authentication. 

Let's walkthrough configuring 2FA on web and mobile using an authenticator app. 

### Configuring 2FA on the Web 

To enable 2FA on GitHub's webpp, follow these steps:

1. Download an authenticator app. I'm using [Microsoft Authenticator](https://www.microsoft.com/en-us/security/mobile-authenticator-app).  

2.  In your GitHub account, go to **Settings** 
    ![go to settings](https://user-images.githubusercontent.com/47188731/221370602-9cda7bef-aea5-4902-9612-1b7d8dae08c7.png)

3. Under Access, select **Password and authentication** 
    ![Password and authentication](https://user-images.githubusercontent.com/47188731/221370665-ada4d4a1-b83b-4711-87ac-e5bdf497cd46.png)

4. You will then see an option to enable 2FA, click the green button, **"Enable two-factor authentication"**
    ![enable-2fa-screen](https://user-images.githubusercontent.com/122485963/221375469-ca75e2b3-ea0a-4171-a426-1f7b4f4a2c81.png)

5. This will take you to a page to setup your authenticator app. Use the authenticator app you downloaded to scan the QR code on the screen.

    ![scan-qr-code](https://user-images.githubusercontent.com/122485963/221371337-340f3645-1bad-4b4f-8422-e0585352631a.png)

    Once you scan the QR code with the app, enter the generated code in the highlighted text box and click **Continue**.

6. The next screen will ask you to download your recovery codes. Click the green download button and save these codes in a password manager - I love [Bitwarden](https://bitwarden.com/). 

    ![Download recovery codes](https://user-images.githubusercontent.com/122485963/221371553-bc177e7d-9883-4265-9ee2-0a3ebb7b05fa.png)

    After you've downloaded and saved your codes, click the green button "I have saved my recovery codes" to confirm your download and complete enabling 2FA on your account. 

7. And you're done! You've successfully enabled 2FA on your account. 
    ![congrats](https://user-images.githubusercontent.com/122485963/221371803-542a317a-0d9c-4166-9802-f25c6ed9f0e9.png)

You can add a backup 2FA method for your account just in case using a security code (such as a touch ID on mac or a yubikey) or the GitHub mobile app. 

### Configuring 2FA on Mobile  

Getting 2FA enabled on your mobile device is very similar to what we just did on the web app. I'll be using an android device. 

1. Go to the play store on Android or iOS App Store, search for the GitHub Mobile app install it (Im using an Android device). 
    ![GitHub App on Google Play Store](https://user-images.githubusercontent.com/47188731/221691498-75bc5f6e-7f59-4796-be8a-2ad324cd391b.jpg)

2. Once installed, you'll be prompted to sign into your account with your username and password.
    ![Sign in to GitHub Mobile](https://user-images.githubusercontent.com/47188731/221692330-08084e05-05d9-44fe-b1b5-966e82c9ab9b.png)



3. Since we just enabled 2FA on the webapp in our account, we'll be prompted to engter the authentication code from the authenticator app we previously downloaded. Enter the code and click **Verify** 

    ![2FA screen on mobile](https://user-images.githubusercontent.com/47188731/221692711-4b2bef16-1565-4672-8ed7-61a9b4d82687.jpg)


4. Onced verified, you'll be prompted to authorize your GitHubHub mobile app with your GitHub account. Select **Authorize github** to continue 
    ![Authorize GitHub on Mobile](https://user-images.githubusercontent.com/47188731/221692792-c6887b1a-4ea0-4f69-86f5-9905582476dd.jpg)


5. Once authorized, you'll be rerouted to the Home screen on mobile. 
    ![GitHub Mobile Homescreen](https://user-images.githubusercontent.com/47188731/221692899-a918a0a0-1fae-44dd-8a88-49089dd9abc1.jpg)


### Wrapup 

And that's it! You've successfully enabled 2FA on GitHub web and mobile. Now GitHub your account is more secure. 🔐

If you ever lose access to your 2FA credentials, you can use your recovery codes to gain access to your GitHub account. Learn how to use your recovery codes by reading the GitHub docs on [Recovering your account if you lose your 2FA credentials](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/recovering-your-account-if-you-lose-your-2fa-credentials). You can also learn more about 2FA by [reading the docs on GitHub](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/about-two-factor-authentication).