> ## Documentation Index
> Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Demo Enable 2FA

> How to enable and configure two-factor authentication on GitHub, choosing authenticator apps or security keys and securely storing recovery codes

In this lesson you'll learn how to enable two-factor authentication (2FA) for a GitHub account, review the available sign-in methods, and choose the most secure option for your workflow. We'll cover the authentication options listed on the GitHub "Password and authentication" page, how to register an authenticator app, and where to store recovery codes.

## 1. Open GitHub account settings

* Sign in to GitHub and go to **Settings** → **Access** → **Password and authentication**.
* This page lists the sign-in methods available to your account and what is already configured. For example, an account that uses Google single sign-on will show no local password configured but will list verified email addresses and other sign-in options such as Apple, passkeys, and biometric/passwordless sign-in.

Clicking **Add passkey** starts the passkey registration flow on your device (this may trigger an OS prompt or browser dialog). If the registration fails or you decide not to proceed, click **Cancel** to return to the settings page.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/8a2vUt44Q-mRlkru/images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-passwordless-authentication-failed.jpg?fit=max&auto=format&n=8a2vUt44Q-mRlkru&q=85&s=540c738ec85be763ec130693d986041d" alt="The image shows a GitHub interface for configuring passwordless authentication with a notification that &#x22;Passkey registration failed.&#x22; There are options to add a passkey or cancel the process." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-passwordless-authentication-failed.jpg" />
</Frame>

## 2. Locate Two-factor authentication

Scroll to the **Two-factor authentication** section on the "Password and authentication" page. If you haven't enabled 2FA for the account yet, you'll see an option to enable it.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/8a2vUt44Q-mRlkru/images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-password-authentication-settings-two-factor-authentication.jpg?fit=max&auto=format&n=8a2vUt44Q-mRlkru&q=85&s=0b325107086d9307477bd186171c271e" alt="The image shows a GitHub &#x22;Password and authentication&#x22; settings page, indicating that two-factor authentication is not enabled, with an option to enable it." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-password-authentication-settings-two-factor-authentication.jpg" />
</Frame>

## 3. Choose an authenticator app (recommended)

GitHub recommends using an authenticator app to generate time-based one-time passwords (TOTP). Popular choices include:

* [1Password](https://1password.com/)
* [Microsoft Authenticator](https://www.microsoft.com/en-us/security/account-protection/microsoft-authenticator-app)
* [Google Authenticator](https://support.google.com/accounts/answer/1066447)

When you select to set up with an authenticator app, GitHub displays a QR code that your authenticator app can scan. The app will then generate a 6-digit code (TOTP) that you enter into GitHub to verify the setup.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/8a2vUt44Q-mRlkru/images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-2fa-authenticator-app-qr-code.jpg?fit=max&auto=format&n=8a2vUt44Q-mRlkru&q=85&s=ca5a6ef7c1b507eaf9f02c5318a4784b" alt="The image shows a GitHub webpage prompting the user to enable two-factor authentication (2FA) using an authenticator app. It includes a QR code for scanning and a field to enter a verification code." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-2fa-authenticator-app-qr-code.jpg" />
</Frame>

Steps to enable 2FA with an authenticator app:

1. Open your authenticator app on your mobile device (Google Authenticator, Microsoft Authenticator, 1Password, etc.).
2. Scan the QR code displayed in GitHub or manually enter the provided secret.
3. Enter the 6-digit code generated by the app into GitHub and submit.
4. GitHub verifies the code and completes the setup.

After verification, GitHub will show that the authenticator app is configured as a second factor and will provide recovery codes.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/8a2vUt44Q-mRlkru/images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-settings-two-factor-authentication-enabled.jpg?fit=max&auto=format&n=8a2vUt44Q-mRlkru&q=85&s=31231fea6a281230e9a6d51d802417fe" alt="The image shows a GitHub settings page for configuring two-factor authentication, with a message indicating that two-factor authentication has been enabled using an authenticator app. Confetti is visible on the screen, likely celebrating the completion of the setup." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-settings-two-factor-authentication-enabled.jpg" />
</Frame>

## 4. Recovery codes and account recovery

GitHub provides one-time recovery codes that allow access if you lose your authenticator device. Save these codes immediately after setup:

* Store recovery codes in a reputable password manager (for example, [1Password](https://1password.com/)).
* Consider using authenticator apps with encrypted cloud backup (for example, [Authy](https://authy.com/)) to make TOTP recovery easier—but do not rely solely on backup features in place of securely stored recovery codes.
* You can download or view recovery codes from the GitHub UI. See GitHub Docs: [Managing two-factor authentication recovery codes](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa/managing-two-factor-authentication-recovery-codes).

Once setup is complete, the Two-factor authentication section will indicate that 2FA is enabled and list all configured second-factor methods.

<Frame>
  <img src="https://mintcdn.com/kodekloud-c4ac6d9a/8a2vUt44Q-mRlkru/images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-security-settings-two-factor-authentication.jpg?fit=max&auto=format&n=8a2vUt44Q-mRlkru&q=85&s=30006d144f465ba67945e6200e6502c8" alt="The image shows a GitHub security settings page focused on two-factor authentication options, including the use of an authenticator app, SMS/text message, security keys, and GitHub Mobile for enhanced account security." width="1920" height="1080" data-path="images/GitHub-Foundations-Certification/Authentication-and-Security/Demo-Enable-2FA/github-security-settings-two-factor-authentication.jpg" />
</Frame>

## 5. Compare available 2FA options

| Method                            | Security level | Notes / best use                                                                |
| --------------------------------- | -------------- | ------------------------------------------------------------------------------- |
| Authenticator app (TOTP)          | High           | Recommended for most users. Works offline and resists SIM-based attacks.        |
| Hardware security keys / Passkeys | Very high      | Phishing-resistant; use for highest protection (YubiKey, platform keys).        |
| GitHub Mobile (push approval)     | High           | Convenient; supports push-based approvals for quick authentication.             |
| SMS / Text messages               | Low            | Available but vulnerable to SIM swap and interception; avoid as primary method. |

## Final recommendations

* Prefer authenticator apps or hardware security keys over SMS.
* Save recovery codes to a secure location right after setup.
* Consider using a password manager that supports secure storage of recovery codes and passkeys.

<Callout icon="lightbulb" color="#1CB2FE">
  Save recovery codes immediately after setup and store them in a secure place (for example, a reputable password manager). Avoid relying on SMS as your primary second factor when stronger options (authenticator apps or security keys) are available.
</Callout>

References:

* GitHub Docs: [Securing your account with two-factor authentication (2FA)](https://docs.github.com/en/authentication/securing-your-account-with-two-factor-authentication-2fa)
* 1Password: [https://1password.com/](https://1password.com/)
* Authy: [https://authy.com/](https://authy.com/)
* Microsoft Authenticator: [https://www.microsoft.com/en-us/security/account-protection/microsoft-authenticator-app](https://www.microsoft.com/en-us/security/account-protection/microsoft-authenticator-app)
* Google Authenticator: [https://support.google.com/accounts/answer/1066447](https://support.google.com/accounts/answer/1066447)
* GitHub Mobile: [https://github.com/mobile](https://github.com/mobile)

<CardGroup>
  <Card title="Watch Video" icon="video" cta="Learn more" href="https://learn.kodekloud.com/user/courses/github-foundation-certification/module/ea947699-ceb4-48b5-bde9-d0de4c959c2e/lesson/9d462301-ce78-49b2-83cd-9eb821215d83" />
</CardGroup>
