Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
Below are step‑by‑step instructions to remediate missing Two‑Factor Authentication (2FA) for GitHub access, using only the GitHub web console. There are two parts:
- Enable 2FA on each user account.
- (If you’re an org owner) Enforce 2FA at the organization level.
1. Enable 2FA on a GitHub User Account
Do this for each user that needs 2FA:-
Sign in to GitHub:
https://github.com/login -
Go to your profile settings:
- Top‑right corner → click your avatar
- Click Settings
-
Open security settings:
- In the left sidebar, click Password and authentication (or Account security depending on UI).
-
Start 2FA setup:
- Under Two‑factor authentication, click Enable two-factor authentication or Set up two-factor authentication.
-
Choose an authentication method:
A. Using an authenticator app (recommended)
- Select Set up using an app (or similar wording).
- Install an app on your phone (e.g., Authy, Google Authenticator, 1Password, Microsoft Authenticator).
- Scan the QR code shown in GitHub using the app.
- The app will show a 6‑digit code. Enter that code into GitHub to verify.
- Click Enable or Continue.
- Select Set up using SMS.
- Enter your phone number and click Continue.
- Enter the code sent via SMS.
- Click Enable.
-
Save recovery codes (critical):
- GitHub will show Recovery codes after enabling 2FA.
- Click Download, Print, or Copy these codes and store them in a secure place (password manager or secure offline storage).
- Confirm you’ve saved them.
-
(Optional but strongly recommended) Add a security key:
- Under Security keys, click Register new security key.
- Insert your FIDO2/U2F key (e.g., YubiKey) when prompted and follow the instructions.
- This becomes an extra 2FA method.
2. Enforce 2FA for a GitHub Organization (GitHub IAM control)
Perform this if you are an owner of a GitHub organization and want to require all members to use 2FA:- Sign in with an owner account that already has 2FA enabled.
-
Go to your organization:
- Top‑right avatar → Your organizations
- Click the org name.
-
Open org settings:
- In the org page, click Settings (top or left sidebar, depending on UI).
-
Go to security section:
- In the left sidebar, click Security, Authentication security, or Organization security (name may vary slightly).
- Look for Two‑factor authentication or Require authentication options.
-
Enable the 2FA requirement:
- Find Require two-factor authentication for all members, outside collaborators, and billing managers.
- Check the box or toggle it On.
-
Review impact notice:
- GitHub will warn that members without 2FA will be removed from the organization after a grace period (or immediately, depending on current GitHub behavior).
- Review the list of affected users if provided.
-
Confirm the change:
- Click Save, Update, or Confirm.
- Acknowledge any warning prompts.
Summary of Remediation
- Ensure every user with GitHub access to your environment enables 2FA (Step 1).
- As an org owner, enforce “Require two-factor authentication” on the organization (Step 2).
- Make sure users securely store recovery codes and ideally register a security key to reduce account lockout risk.
Using CLI
Using CLI
Below are the concrete steps to enforce Two‑Factor Authentication (2FA) for a GitHub organization using the GitHub CLI (
If it prints:then 2FA is currently not enforced.
Verify:If now:2FA is enforced.
Run it:
If you want, I can provide a ready‑made compliance check script that scans all orgs under your account and enforces 2FA where missing.
gh).Note: Individual users must enable 2FA themselves via the web UI; the CLI can enforce 2FA at the organization level, not directly turn it on for user accounts.
1. Prerequisites
-
Install GitHub CLI (if not already):
-
Authenticate with an organization owner account:
- Choose GitHub.com / HTTPS.
- Log in with a browser.
- Ensure the token has
admin:orgscope (or at least enough to manage org settings).
-
Identify your organization name:
- This is the org slug shown in URLs like
https://github.com/<org-name>.
- This is the org slug shown in URLs like
2. Check Current 2FA Enforcement Status
ReplaceORG_NAME with your organization:3. Get Members Without 2FA (Impact Assessment)
Before enforcing 2FA, list members who do not have 2FA enabled (they will be removed from the org when you enforce it):- Save or share this list with your team; tell them to enable 2FA first.
4. Enforce 2FA on the Organization
Run:Important: All members without 2FA will be removed from the organization when the setting is turned on. They can rejoin once they enable 2FA.
5. (Optional) Scripted / Idempotent Remediation
Example bash script to enforce 2FA with a pre‑check and a warning:6. User Instructions (What to Tell Affected Users)
You cannot enable 2FA for users via CLI, but you should direct them to:- Go to:
https://github.com/settings/security - Under “Two‑factor authentication”, click Enable two-factor authentication.
- Choose app‑based (recommended) or SMS as backup.
- Save recovery codes.
- Once done, they can be re‑invited to the org or rejoin via SSO/enterprise invites as applicable.
If you want, I can provide a ready‑made compliance check script that scans all orgs under your account and enforces 2FA where missing.
Using Python
Using Python
Below is a concise, step‑by‑step way to enforce and audit 2FA for a GitHub organization using Python.
Effect:
Once this is enabled, any member without 2FA will be removed from the organization when they next attempt to access, or immediately depending on current GitHub behavior. Make sure you communicate before enforcing.
Use this list to:
1. What “remediating 2FA” means in GitHub
For GitHub “IAM”, remediating 2FA typically means:- Enforcing 2FA at the organization level (members must have 2FA).
- Auditing current members and dealing with those without 2FA.
admin:org scope.2. Create a Personal Access Token (PAT)
- Go to
https://github.com/settings/tokens→ “Fine-grained tokens” or “Personal access tokens (classic)”. - Create a token with at least:
admin:org(manage organization settings)
- Save the token; you’ll use it in the Python script as
GITHUB_TOKEN.
3. Enforce 2FA at the Org Level (Python)
This setsmembers must have two-factor authentication enabled = ON.Once this is enabled, any member without 2FA will be removed from the organization when they next attempt to access, or immediately depending on current GitHub behavior. Make sure you communicate before enforcing.
4. Audit Users Without 2FA (Before or After Enforcing)
You can list org members who do not have 2FA enabled:- Notify users to enable 2FA.
- Track remediation progress.
5. (Optional) Remove Non‑2FA Users Programmatically
If you do not want to globally turn on the org 2FA requirement yet, you can selectively remove non‑2FA users:6. Summary
- Generate PAT with
admin:org. - Audit non‑2FA users via
GET /orgs/{org}/members?filter=2fa_disabled. - Enforce 2FA for the org via
PATCH /orgs/{org}withrequire_two_factor_authentication: true. - Optionally, script removal of non‑2FA accounts for controlled rollout.
requests or PyGithub, I can adapt a ready‑to‑run script.Using Terraform
Using Terraform
Terraform cannot enable GitHub multi-factor authentication for a user; the GitHub provider does not expose any argument or resource to manage MFA/2FA on accounts.You must remediate this directly in GitHub:
- Log in as the affected user to
https://github.com. - Go to Settings → Password and authentication → Two-factor authentication.
- Click Enable two-factor authentication and follow the wizard (choose app-based or SMS-based, store recovery codes).
terraform plan will show no changes related to MFA.
