Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To require MFA (2FA) for members in a GitHub organization using the GitHub web console:
-
Sign in to GitHub
- Log in to https://github.com with an account that is an owner of the organization.
-
Go to the organization settings
- Click your profile avatar (top-right).
- Click Your organizations.
- Click the organization name.
- In the org view, click Settings (top menu, typically to the right).
-
Open the Security settings
- In the left sidebar, under Security, click Authentication security (in some UIs it may appear as Security > Authentication or similar).
-
Require 2FA for organization members
- Find the section Two-factor authentication or Require two-factor authentication for everyone in your organization.
- Read the warning: members without 2FA will be removed from the org after a grace period or immediately (depending on current behavior/UI).
- Check the box Require two-factor authentication for everyone in this organization (or similarly named checkbox).
- Click Save / Enable / Update settings (button text varies slightly).
-
Confirm and enforce
- GitHub will show a confirmation dialog explaining that:
- Users (and possibly bots) without 2FA will lose access to the org.
- Confirm the action.
- GitHub will show a confirmation dialog explaining that:
-
Inform members
- Communicate to all org members that:
- They must enable 2FA at Settings → Password and authentication → Two-factor authentication on their user profile.
- If they are removed due to missing 2FA, they can re-enable 2FA and then be re-invited.
- Communicate to all org members that:
Using CLI
Using CLI
To require MFA (2FA) for all members of a GitHub organization using the GitHub CLI (
This will:
If you need a dry run (identify users without 2FA before enforcing), that requires GitHub Enterprise/audit log or a separate script using REST/GraphQL to list users and check
gh), you need to set the org setting two_factor_requirement_enabled to true.Prereqs- You are an organization owner.
ghis installed and authenticated (gh auth login) with a token that hasadmin:orgscope.
1. Authenticate (if not already)
2. Verify current 2FA requirement status
ReplaceYOUR_ORG with your organization name:true→ already enforcedfalse→ not yet enforced
3. Enable MFA requirement for all members
- Enforce 2FA for all org members, outside collaborators, and billing managers.
- Automatically remove users who do not have 2FA enabled from the org (they can rejoin after enabling 2FA).
4. Confirm it’s enabled
If you need a dry run (identify users without 2FA before enforcing), that requires GitHub Enterprise/audit log or a separate script using REST/GraphQL to list users and check
two_factor_authentication on their user objects, but the enforcement itself is via the PATCH command above.Using Python
Using Python
To require MFA for all members of a GitHub organization using Python, you actually enforce “Require two-factor authentication for this organization” at the org level. Users without 2FA will be removed from the org when they next access it.Below are step‑by‑step instructions and a Python example.
Body parameter to enforce MFA for members:The key field is:
3. Simple Python Script (using
Or check in GitHub UI:
Organization Settings → Security → Authentication security → Require two-factor authentication for everyone in the organization should be enabled.
1. Prerequisites
- You must be an organization owner.
- Create a Personal Access Token (classic) or fine‑grained PAT with:
admin:orgscope (for classic), or equivalent on the organization.
- Note:
ORG_NAME– your GitHub organization’s login (e.g."my-org").GITHUB_TOKEN– your PAT.
2. API Endpoint
GitHub REST API (v3):two_factor_requirement_enabled: true3. Simple Python Script (using requests)
4. Validate the Configuration
You can verify via API:Organization Settings → Security → Authentication security → Require two-factor authentication for everyone in the organization should be enabled.
5. Important Behavior Note
- When
two_factor_requirement_enabledis set totrue, members without 2FA are:- prevented from accessing org resources, and
- may be removed from the organization according to GitHub’s behavior and your org’s settings.
- Inform users before enabling this, so they can set up 2FA.
Using Terraform
Using Terraform
terraform plan should show two_factor_requirement_enabled changing from false (or null) to true on github_organization_settings.members_mfa_required.
