SaveMyCert
Log in
5 of 5 free questions left today·for 30 a day
Understand privacy, security, and administration

GitHub Security and Access Management: 2FA, Passkeys, Roles and Branch Protection (GH-900)

14 min readGH-900 · Understand privacy, security, and administrationUpdated

GitHub security and access management is how you protect accounts and decide who can do what on GitHub: two-factor authentication and passkeys for sign-in, repository and organization roles for access, visibility settings, branch protection rules and rulesets for important branches, and enterprise controls such as Enterprise Managed Users and Copilot policies. This lesson covers every GitHub Foundations (GH-900) skill in the security and access management task, with the near-twin distinctions (Triage or Write, Maintain or Admin, member or outside collaborator, private or internal) that the exam relies on.

What you’ll learn
  • Describe GitHub's 2FA methods, recovery codes and passkeys, including synced versus device-bound passkeys
  • Explain what happens to members, billing managers and outside collaborators when an organization requires 2FA
  • Choose the least-privilege repository role (Read, Triage, Write, Maintain, Admin) and organization role for a task
  • Explain base permissions, outside collaborators and how teams, secret teams and nested teams grant access
  • Compare public, private and internal visibility and the effects of changing a repository's visibility
  • Configure branch protection rules and rulesets, including defaults, admin bypass and how rules combine
  • Explain the purpose of Enterprise Managed Users and how Copilot policies are managed across an enterprise

How to secure a GitHub account with two-factor authentication

Two-factor authentication (2FA) secures a GitHub account by asking for a second proof of identity after the password, so a stolen password alone is not enough to sign in. You set it up under Settings › Password and authentication.

GitHub supports these second factors:

  • Authenticator app (TOTP): a time-based one-time code from an app on your phone or computer. This is the recommended starting method.
  • SMS: a code sent by text message. It works, but it is the weakest option and is not offered in every country.
  • Security keys: FIDO2/WebAuthn hardware keys or built-in authenticators, used with a touch, PIN or biometric.
  • GitHub Mobile: approve the sign-in in the GitHub app on a phone you have signed in on.
  • Passkeys: covered in the next section; they replace the password and the second factor together.

Other credentials are not second factors. An SSH key authenticates Git operations, and a personal access token authenticates Git over HTTPS and API calls; neither completes a web sign-in. The verification code GitHub emails when you sign in from an unrecognised device is a check for accounts without 2FA, not a 2FA method you can choose.

Recovery codes and recovery methods

When you enable 2FA, GitHub has you download recovery codes. Each code can be used once to finish signing in when your second factor is unavailable, for example after losing the phone that holds your authenticator app. Store them somewhere safe and separate from that device, and add more than one method (a security key or GitHub Mobile as well as the app). A password reset does not remove 2FA, and GitHub Support cannot switch off 2FA or restore access for you without a recovery factor. The last resort is an account recovery request: you prove ownership with a verified device, an SSH key or a personal access token, and GitHub Support reviews the request, which can take a few business days. An account with no working factor, no recovery codes and none of those recovery factors can be lost permanently.

What passkeys are and how synced and device-bound passkeys differ

A passkey is a passwordless credential: a public/private key pair held by an authenticator (a laptop, phone, password manager or hardware key) and unlocked with a fingerprint, face, PIN or device password. Signing in with a passkey satisfies both the password step and the 2FA step in one action.

Passkeys are phishing-resistant because each one is bound to the website's domain: the browser will not offer a GitHub passkey to a lookalike site at a different address. Codes from an authenticator app or SMS, by contrast, can be typed into a fake page and relayed to the real one.

TypeWhere it livesWhat that means
Synced passkeyA cloud-backed service such as iCloud Keychain, Google Password Manager or a password managerAvailable on every device signed in to that service; survives losing one device
Device-bound passkeyOne authenticator, such as a FIDO2 hardware security keyCannot be copied or backed up; the hardware key itself can be carried between computers

GitHub does not sync passkeys itself; syncing (or not) depends on the authenticator that stores the passkey. If you already registered a security key for 2FA, GitHub may offer to upgrade an eligible security key to a passkey so it can also replace your password.

What happens when an organization requires 2FA

Organization owners can require two-factor authentication for everyone who works in the organization: members, outside collaborators and billing managers. Turning the requirement on treats people without 2FA differently by role:

Who lacks 2FAResult
Members and billing managersKeep their membership (and still use a seat) but cannot access the organization's resources until they enable 2FA
Outside collaboratorsAre removed from the organization's repositories, including their forks of private ones; they can be invited back after enabling 2FA

Owners can also select Only allow secure two-factor methods. With this option, passkeys, security keys, authenticator apps and GitHub Mobile are accepted, but SMS is not: a member whose only second factor is SMS (or who still has SMS configured) is blocked from the organization's resources until they switch to a secure method. Enterprise owners can enforce the same requirement across all of an enterprise's organizations.

Repository roles in an organization: Read, Triage, Write, Maintain and Admin

Repositories owned by an organization offer five built-in roles, each adding to the one before it. Pick the lowest role that covers the job (least privilege).

RoleIntended forAdds
ReadPeople who view or discuss the projectView and clone code, open and comment on issues and pull requests
TriagePeople who manage issues and pull requests without code accessApply labels, assign people, close, reopen and mark duplicates; no push
WriteContributorsPush to branches, merge pull requests, manage releases
MaintainProject managers who run the repositoryEdit description and topics, wikis, merge options, Pages and interaction limits, without sensitive or destructive actions
AdminPeople who need full controlManage access, branch protection and rulesets, visibility, webhooks and deploy keys; delete, archive or transfer the repository

The line between Maintain and Admin is a common source of confusion: protecting a branch counts as a sensitive action, so a Maintain user cannot create or change branch protection rules or rulesets. Organization owners have admin access to every repository in the organization. Enterprise Cloud organizations can also define custom repository roles that start from one of these and add specific permissions.

Repositories owned by a personal account

A repository in a personal account has only two levels: the owner and collaborators. Collaborators can push, manage issues and pull requests and more, but only the owner can invite collaborators, change visibility or delete the repository. There is no Triage or read-only collaborator role on a private personal repository. When you need finer roles, create the repository in an organization or transfer it to one.

Organization roles and base permissions

Organization roles decide what a person can do across the whole organization, separately from their role on any single repository.

RoleWhat it allows
OwnerComplete administrative access to the organization, its settings, people and repositories. Keep at least two owners so the organization is never stranded.
MemberThe default role: can create repositories and projects (if allowed) and receives the base permission on every repository
ModeratorMembers who can block and unblock users and manage interaction limits and comments across public repositories
Billing managerViews and changes payment methods, plans and receipts; no access to repositories
Security managerAssigned to members or teams: views and manages security alerts and security settings across the organization, with read access to all repositories
GitHub App managerManages the settings of some or all GitHub Apps the organization owns
Outside collaboratorNot a member: has access only to the specific repositories they are added to, cannot join teams, and is not given base permissions

Outside collaborators suit contractors and consultants who need one or two repositories for a limited time. Organizations on Enterprise Cloud can also create custom organization roles that bundle selected organization permissions.

Base permissions

The base permission, set by owners under Settings › Member privileges, is the default access every member has to all of the organization's repositories, including repositories created later. The options are No permission, Read, Write and Admin. It is a floor, not a ceiling: if a member gets higher access to a particular repository (directly or through a team), the higher level applies there. Base permissions never apply to outside collaborators. Granting the same access team by team has to be repeated for every new repository, which is the practical difference from a base permission.

How teams organize people and access

A team is a group of organization members that you can grant repository access to, @mention, and request reviews from as one unit. Teams belong to a single organization and contain members only; outside collaborators cannot be added to them.

  • Visible teams can be seen and @mentioned by every member of the organization.
  • Secret teams are visible only to their own members and to organization owners, which suits confidential work.
  • Nested teams: a team can have one parent and several child teams. Child teams inherit the parent's repository access, and mentioning a parent also notifies the members of its children. Secret teams cannot be nested: they can have neither a parent nor children.
  • Team maintainers can change the team's name, description and visibility, add and remove organization members, and manage team review settings, all without being organization owners.

Because a secret team cannot sit under a parent, hiding a team and giving it inherited access are mutually exclusive: a secret team gets repository access only through direct grants.

Repository visibility: public, private and internal

A repository's visibility decides who can see it at all, before any role applies.

VisibilityWho can see it
PublicEveryone on the internet
PrivateOnly the owner and the people and teams explicitly given access (plus members through the base permission, in an organization)
InternalEvery member of the enterprise, across all its organizations, but not the public or outside collaborators. Available only to organizations owned by a GitHub Enterprise Cloud (or Server) enterprise.

Internal visibility supports InnerSource: code shared across every organization in a company without being public. A private repository cannot do the same job, because its base permission covers only its own organization and teams from other organizations cannot be added to it.

Changing visibility

Changing a public repository to private controls who sees it from now on, but cannot recall copies already made: stars and watchers are erased, and existing public forks stay public and are detached into a separate network. People with explicit access keep it, and the commit history is unchanged. On GitHub Free, a published GitHub Pages site is unpublished. Only repository admins (or owners) can change visibility, and organization owners can restrict this to owners.

Restricting repository creation

Under Member privileges, owners choose whether members can create repositories and of which visibility, for example private only, so members cannot accidentally publish sensitive code. Owners can always create any type. Base permissions, branch protection and rulesets act on repositories that already exist, so they do not control this.

Branch protection rules

A branch protection rule enforces how changes reach an important branch, such as main. Repository admins create rules under Settings › Branches, matching a branch name or pattern. Protected branches are available in public repositories on GitHub Free and in public and private repositories on GitHub Pro, Team and Enterprise Cloud.

A rule can require:

  • a pull request before merging, with a number of approving reviews (and optionally review from code owners, or dismissal of stale approvals);
  • status checks, such as a CI build, to pass;
  • conversation resolution before merging;
  • signed commits or a linear history;
  • a locked (read-only) branch, or restrictions on who can push.

Two defaults matter. First, once a rule matches a branch, force pushes and branch deletion are blocked even though you did not select anything for them; you can choose to allow them. Every other requirement, such as status checks or signed commits, is off until selected. Second, administrators bypass the rule by default. To make the rule bind admins too, enable Do not allow bypassing the above settings. Only one branch protection rule applies to a given branch. A CODEOWNERS file only requests reviews from owners; it enforces nothing unless a rule requires code owner review.

Rulesets and how they combine with branch protection

A ruleset is a named collection of rules for branches or tags in a repository, offered alongside branch protection. Rulesets cover the same kinds of rules but work differently:

Branch protection ruleRuleset
Rules per branchOne rule applies to a branchSeveral rulesets can target the same branch, together with a branch protection rule
When they overlapNot applicableRules aggregate; where the same rule differs, the most restrictive version applies (there is no priority order)
PausingDelete or edit the ruleSet the enforcement status to Disabled; the configuration is kept (Active enforces; Evaluate, for testing, is on Enterprise plans)
ExemptionsAdmins bypass unless blocked from bypassingA bypass list names roles, teams or GitHub Apps that may skip the rules
Who can see themManaged under the repository's admin-only SettingsAnyone with read access can see active rulesets
TargetsBranchesBranches or tags

Because rules aggregate to the most restrictive, a second, looser ruleset can never relax a stricter one. To exempt a release bot, add it to the bypass list; giving it more repository permission does not exempt it. Creating and editing rulesets, like branch protection, requires the Admin role.

Enterprise Managed Users and Copilot policy management

Enterprise Managed Users (EMU) is a type of GitHub Enterprise Cloud enterprise in which the company's identity provider (IdP) creates and controls every user account. The IdP provisions accounts through SCIM, sets their usernames, profile data and email, controls organization and team membership, and handles sign-in through SAML or OIDC. Deactivating someone in the IdP removes their GitHub access.

The trade-off is isolation. Managed user accounts can only create private or internal content inside the enterprise. Outside it they can view public repositories, but cannot push, open issues or pull requests, comment, react, star, watch or fork, and cannot create public repositories or create gists of any visibility. A developer who also contributes to open source needs a separate personal account.

Enterprise typeAccountsFits when
Enterprise Managed UsersOwned and provisioned by the company IdPThe company needs full control of identities and content stays inside the enterprise
Personal accounts + SAML SSODevelopers' own GitHub accounts, which must authenticate through the IdP to reach company resourcesDevelopers use one account for company work and public open source

Organization-wide Copilot policy management

For Copilot Business and Copilot Enterprise, organization owners decide which members receive a Copilot seat and set the organization's Copilot policies (which features, models and settings are allowed). Repository admins and billing managers do not control these. In an enterprise, enterprise owners set each policy first: they can enable or disable it for every organization, or choose to let organizations decide, which hands that choice to each organization's owners. When a user receives Copilot from organizations with different settings, GitHub generally applies the least restrictive setting. Choosing between Copilot plans and features is covered in the GH-900 lesson on GitHub Actions, Copilot and Codespaces; account types are covered in the accounts lesson.

Tip. Questions are short scenarios that ask which role, setting or method fits a stated need, often with a constraint such as granting the least access, blocking someone from pushing, giving access to a non-member, hiding something from the public or keeping a user's existing admin rights. Expect near-twins: Read, Triage, Write, Maintain or Admin; owner, billing manager, security manager, moderator or outside collaborator; base permission or team grant; visible or secret team; public, private or internal; synced or device-bound passkey; a member blocked or an outside collaborator removed; Enterprise Managed Users or personal accounts with SAML SSO; enabled, disabled or left to organizations for a Copilot policy. Some items check defaults (force pushes and deletion blocked, admins bypassing branch protection) or what happens after a change such as making a repository private. Harder items combine two facts, such as layered rulesets plus branch protection, and a few are select-TWO.

Key takeaways
  • Save your 2FA recovery codes: GitHub Support cannot switch off 2FA, and an account recovery request needs a verified device, SSH key or personal access token.
  • A passkey replaces both password and 2FA, is phishing-resistant, and is either synced by a cloud service or bound to one device.
  • When 2FA is required, members without it stay but are blocked; outside collaborators without it are removed. The secure-methods option also blocks SMS.
  • Triage manages issues and pull requests without push; Maintain manages settings without access, branch protection or deletion, which need Admin.
  • Personal-account repositories have only owner and collaborators; move to an organization for finer roles.
  • Base permissions apply to every member on every repository, never to outside collaborators, and a higher grant wins.
  • Child teams inherit their parent's access; secret teams are hidden but cannot be nested.
  • Internal visibility shares a repository across an Enterprise Cloud enterprise without making it public.
  • Branch protection blocks force pushes and deletion by default, but admins bypass it unless bypassing is disallowed.
  • Rulesets layer: the most restrictive version of each rule applies, and a bypass list exempts named actors.

Frequently asked questions

What should I do if I lose my phone with my GitHub 2FA app?

Sign in with one of the recovery codes you saved when you set up two-factor authentication, or use another configured method such as a security key, passkey or GitHub Mobile. A password reset does not remove 2FA, and GitHub Support cannot switch it off. The last resort is an account recovery request, which needs a verified device, an SSH key or a personal access token and is reviewed by GitHub Support; without a recovery code, another method or one of those factors, the account may be lost.

Is a GitHub passkey the same as 2FA?

A passkey is a passwordless sign-in method that satisfies both the password step and the two-factor step at once. It is phishing-resistant because it only works on github.com's domain. Synced passkeys are backed up by a service such as iCloud Keychain or a password manager; device-bound passkeys stay on one authenticator such as a hardware key.

What is the difference between the Triage and Write roles on GitHub?

Triage lets a person manage issues and pull requests (apply labels, assign people, close, reopen and mark duplicates) without pushing code. Write adds pushing to branches and merging pull requests. Choose Triage for community or project managers who must not change code.

Who can create branch protection rules on GitHub?

People with the Admin role on the repository, and organization owners, who have admin access to every organization repository. The Maintain role cannot create or change branch protection rules or rulesets, because protecting branches is treated as a sensitive action.

What is an outside collaborator in a GitHub organization?

An outside collaborator is someone with access to one or more of an organization's repositories who is not a member of the organization. They do not receive the members' base permission, cannot be added to teams, and are removed if the organization requires 2FA and they have not enabled it.

What is the difference between private and internal repositories?

A private repository is visible only to people and teams given access, plus members through their organization's base permission. An internal repository is visible to every member of an Enterprise Cloud enterprise, across all its organizations, but not to the public. Internal visibility exists only for organizations owned by an enterprise.

When should a company use Enterprise Managed Users?

Use Enterprise Managed Users when the company must create, name and deactivate every GitHub account from its identity provider and keep work inside the enterprise. Managed users cannot contribute to repositories outside the enterprise, so companies whose developers use one account for open source choose personal accounts with SAML single sign-on instead.

What happens when two rulesets apply to the same branch?

GitHub combines the rules from every active ruleset and any branch protection rule on the branch. Where the same rule is set differently, the most restrictive version applies, so a second, looser ruleset cannot relax a stricter one. Actors on a ruleset's bypass list can skip that ruleset's rules.

Source

This lesson covers the "Understand privacy, security, and administration" domain of the official GH-900 exam guide. Vendors revise their guides — check the source for the current version.

Test yourself on this topic
GH-900 practice questions, with full explanations.
Practice now

Sign up free to mark lessons complete, bookmark topics and track your exam readiness.

Spotted a mistake in this lesson?