Two-factor authentication(2FA) adds an extra layer of security to your GitHub account. In addition to your username and password, you’ll need to enter a code that GitHub sends to you via text or an app on your phone or tablet.
Two ways to setup
Authenticator app option: Use an application on your phone to get two-factor authentication codes when prompted.
SMS option : GitHub will send you an SMS with a two-factor authentication code when prompted. Please note that, SMS option is only available in certain countries.
How to enable
Log on to your GitHub account.
You can click on Setting menu item from the profile menu in the top right corner.
Click on the Security tab in the Personal settings left menu.
Click on Set up two-factor authentication button as shown below.
Use an Authenticator application on your phone or tablet and scan the bar code.
Enter the random token number displayed on the app where prompted.
Download, print, or copy your recovery codes before you finish enabling two-factor authentication below.
Once you complete the setup process, you can see the Enabled button.
Recovery codes are used to access your account in the event you cannot receive two-factor authentication codes.
Normally, when you sign in to GitHub you’ll enter your username and password.
With 2FA enabled, when logging in, you’ll need to enter an additional code from your phone or tablet.
Once you enter the code, you’ll be logged into GitHub.