How to Set Up Two-Factor Authentication on GitHub

Set up two-factor authentication for secure work on GitHub.

Time to read: less than 5 min

Task

To work securely with repositories, it is necessary to set up two-factor authentication.

Ready Solution

If you manage a repository on GitHub, you have certainly encountered the requirement to set up two-factor authentication. It is needed to ensure secure access to the account and prevent unauthorized access. You can add two-factor authentication by following these steps.

Click on your profile picture button in the main GitHub menu at the top of the page. It is called "Open user account menu" and is located at the very end of the menu.

Main GitHub menu.

In the dropdown menu opened by the button, select "Settings" and go to your profile settings.

Dropdown menu with the link to go to profile settings.

In the sidebar tabs under the "Access" section, expand the "Password and authentication" tab. In the content of the tab, scroll down to the "Two-factor authentication" section with the two-factor authentication settings.

Section "Password and authentication" in profile settings.

Click on the link "Enable two-factor authentication". It is located under the message "Two-factor authentication is not enabled yet".

After following the link, you will be taken to a page with three steps to enable the new authentication method. In the first step, you will be asked to install and open an authentication app on your smartphone. For example, Google Authenticator for iOS/iPadOS or for Android. Scan the QR code on the page. It is located in the "Scan the QR code" section. After that, a special 6-digit code will appear in the app, which you need to enter in the "Verify the code from the app" field. Now click on the "Continue" button, which was previously inactive.

First step with setting up the authentication app.

On the second step page, you need to download the recovery codes. You can download them to your computer using the "Download" button or simply copy them. Next, click on "I have saved my recovery codes".

Downloading recovery codes.

On the third page with the last step, accept congratulations for setting up two-factor authentication. On this page, you can also configure access using SMS messages or the GitHub app (for iOS/iPadOS or for Android). These are the two remaining methods for setting up two-factor authentication.

Page with congratulations on successfully setting up two-factor authentication and additional settings.

After setting up access to your account using the Google Authenticator app, the information in your profile settings under the "Password and authentication" tab will be updated. A dropdown menu with the preferred method of authentication will appear, along with the "Two-factor methods" block. In it, you can edit the settings for authentication apps, SMS, and text messages, security keys, and GitHub Mobile. The last change is the "Recovery options" section.

Profile access settings page with enabled two-factor authentication.

Using the "Preferred 2FA method" field, you can choose a convenient method of two-factor authentication — authentication app, SMS or text message, GitHub Mobile.

Choosing the preferred authentication method.