Securing your account

A password alone is one stolen secret from failure

PASSWORD ONLYPasswordwhoever has it gets inWITH TWO-FACTOR AUTHENTICATIONPassword+A second factoronly you get inauthenticator apppasskey or security keyGitHub Mobiletext message (weakest)Two-factor authentication asks for something you know and something you have.A stolen password is then not enough. The second factor is a code from an authenticator app,a passkey or security key, or GitHub Mobile. GitHub requires it of everyone who contributescode, and an organization can require it of all its members.

Two-factor authentication adds something you have to something you know.

Securing your account · Going deeper

Protecting an account

ProtectionWhat it doesTwo-factor authenticationA second proof at sign-in; required for code contributorsPasskeySigns you in with your device, with no password to stealRecovery codesOne-time codes to save; the way back in if you lose your deviceSSH keyProves your computer to GitHub for Git over SSHPersonal access tokenStands in for your password in scripts; fine-grained ones limit reachSecurity logA record of sign-ins and changes on your accountSAML single sign-onAn organization sends members through the company sign-inSave your recovery codes when you turn two-factor authentication on.Treat tokens and keys like passwords, and never commit them to a repository.

Passkeys, recovery codes, tokens and the security log.

Repository roles

Five roles, each adding to the one before

ReadTriageWriteMaintainAdminView, clone, open issues and comment✓✓✓✓✓Label, assign and close issues✗✓✓✓✓Push, and merge pull requests✗✗✓✓✓Manage settings that are not destructive✗✗✗✓✓Delete, change visibility, manage access✗✗✗✗✓Five repository roles, each adding to the one before.Read is for people who look and discuss. Triage manages issues without touching code. Writeis for contributors. Maintain runs the repository day to day. Admin has full control, includingthe dangerous actions. Give each person the lowest role that lets them do their job.

Read, Triage, Write, Maintain, Admin: give the lowest that works.

Repository roles · Going deeper

How access is given

How access is givenWhat it meansPersonal repositoryTwo levels only: the owner, and collaboratorsOrganization repositoryThe five roles: Read, Triage, Write, Maintain, AdminBase permissionsThe role every member has on every repository of the organizationTeamGive a role to a group once, instead of person by personOutside collaboratorAccess to chosen repositories without being a memberCustom repository roleA role you define yourself, on GitHub Enterprise CloudLeast privilege: the lowest role that lets the person do the work.Someone on several teams gets the highest role any of them grants.

Base permissions, teams and outside collaborators.

Check yourself

Mustlabel, assign and close issuesMust notpush code or change settingsWherea repository owned by an organization

Which role is the lowest that fits this person?

Organizations and enterprises

Teams get roles. Enterprises hold organizations

ORGANIZATION: ACME-APPSTeam: mobile4 membersios-approle: WriteTeam: web6 memberswebsiterole: MaintainENTERPRISE: ACME INC.ORGANIZATION: ACME-DATAits own members, teams,repositories and settingsAn organization holds a group's repositories. An enterprise holds a company's organizations.In an organization, owners manage members, teams and settings, and teams receive roles onrepositories. An enterprise account sits above: one bill, and policies that apply to everyorganization inside it.

An organization holds repositories and teams. An enterprise holds organizations.

Organizations and enterprises · Going deeper

Roles in an organization

Organization roleWhat it can doOwnerEverything: members, teams, billing, settings, deleting the organizationMemberThe default: create repositories and teams if the owners allow itModeratorBlock users and limit interactions in public repositoriesBilling managerSee and change billing, with no access to codeSecurity managerSee security alerts and settings across all repositoriesOutside collaboratorNot a member: reaches only the repositories they were added toKeep at least two owners, so the organization is never locked out.Teams can be nested, and mentioned as @org/team to notify or request review from all members.

Owner, member, billing manager, security manager.

Enterprise Managed Users

Who owns the account: you, or the company

PERSONAL ACCOUNTS: THE USUAL WAYyou create the account, and it is yours;the company invites it to its organization✓contribute anywhere on GitHub✓create public repositories✓keep the account when you change jobsENTERPRISE MANAGED USERSthe company's identity provider creates theaccount, and you sign in through it✓the company controls names, access and removal✗cannot create public content✗cannot contribute outside the enterpriseWith Enterprise Managed Users, the company owns the accounts, not the employees.Accounts are created, updated and removed from the company's identity provider. A manageduser works only inside the enterprise. It is an option of GitHub Enterprise Cloud, chosenwhen the enterprise is created.

With Enterprise Managed Users, the identity provider creates and controls accounts.

Enterprise Managed Users · Going deeper

What an organization can decide

An organization can decideFor exampleBase permissionsEvery member gets Read on every repository, or noneRepository creationWhether members may create public, private or internal repositoriesVisibilityPublic: anyone. Private: people you choose. Internal: the whole enterpriseTwo-factor authenticationRequired for every member and outside collaboratorForkingWhether private repositories may be forkedCopilotWhich Copilot features and models members may useActionsWhich actions and workflows are allowed to runA policy set by the enterprise overrides the choice of its organizations.An organization-wide Copilot policy means members cannot switch the feature on for themselves.

Base permissions, visibility, required 2FA and Copilot policy.

Check yourself

Created bythe company's identity provider, not by MonaSign-inthrough the company's single sign-onLimitsno public repositories, nothing outside the enterprise

What kind of account is mona_acme?

Protected branches

Main accepts changes only through the gate

MAIN IS PROTECTED BY A RULEgit push origin mainrejected: changes must be made through a pull requestPull requestfrom a branchReview1 approval requiredStatus checksthe tests must passMergemain moves forwardA protected branch accepts changes only on your terms.A rule on main can require a pull request, approvals and passing checks, and block force pushesand deletion. Branch protection rules belong to one repository. Rulesets do the same and more:they can cover many branches, tags and repositories.

A branch rule blocks direct pushes and requires a pull request, review and checks.

Protected branches · Going deeper · 1 of 2

What a branch rule can require

A rule canSo thatRequire a pull request before mergingNobody pushes straight to the branchRequire approvalsSomeone else has read the changeRequire review from code ownersThe owners named in CODEOWNERS agreeRequire status checks to passA failing build cannot mergeRequire signed commitsEach commit is verified as coming from its authorBlock force pushes and deletionHistory on the branch cannot be rewritten or lostRepository admins and organization owners set these rules.A ruleset can be tried in evaluate mode first, and can list who may bypass it.

Approvals, code owners, status checks, signed commits.

Protected branches · Going deeper · 2 of 2

Clue words for security and administration

When the question saysThe answer isRemember"a second step at sign-in"Two-factor authenticationapp, passkey, security key"lost the phone with the authenticator"Recovery codessaved in advance"manage issues, but no code access"Triage roleabove Read"push to the repository"Write rolecontributors"manage the repository, not delete it"Maintain rolebelow Admin"give a group access in one step"A team@org/team"visible to everyone in the enterprise"Internal repositorynot public"accounts created by the identity provider"Enterprise Managed Usersno public content"several organizations, one set of policies"Enterprise accountabove organizations"stop direct pushes to main"Branch protection or rulesetrequire a pull request"control Copilot for all members"Organization Copilot policyBusiness or EnterpriseDomain 6 is 10 to 15% of the exam.

2FA, Triage, internal, EMU and rulesets.

Check yourself

Step 1user name and passwordStep 2a six-digit code from an authenticator appIf lostone of the recovery codes saved earlier

What is this sign-in using?

Lesson complete

You finished “Privacy, security and administration”

Answer the questions along the way to see your score here.

Open in a new tab