How-To: Set Up SSH Certificate Authentication in GitHub
Overview - How to Protect Your GitHub Repositories with SSH Certificates
Long-lived SSH keys are one of the easiest ways for an attacker to get to your source code: they never expire, they get copied between laptops, and nobody remembers to remove them. EZSSH takes them out of the equation. Your engineers authenticate with their Entra ID identity and receive a short-lived SSH certificate that GitHub trusts.
This guide covers how to make your GitHub organization trust your EZSSH Certificate Authority (CA), how to map your users to their GitHub usernames, and how to restrict which IP addresses can use the certificates.
Prerequisites for Enabling GitHub SSH Certificates
- You have registered the Keytos application in your Entra ID tenant.
- You have selected an EZSSH plan.
- You have a GitHub Enterprise organization, and you are an owner of it. SSH Certificate Authorities are only available in GitHub Enterprise.
How to Enable GitHub SSH Certificates - Video Tutorial
Want to follow along with our video tutorial? Check out our video below where we walk you through how to enable SSH certificates in GitHub and configure EZSSH to issue them:
Step-by-Step Guide - How to Enable GitHub SSH Certificates
Step 1: How to Enable GitHub Certificates in EZSSH
-
Go to the EZSSH portal.
-
From the left-hand menu, click Settings.
-
Under GitHub access certificates, make sure GitHub certificates are enabled is selected for your subscription.
-
Enter the GitHub Access Certificate Length in hours. This is how often your engineers have to request a new certificate. We set ours to 8 hours, so our engineers only request access once a day.
-
Copy the CA Public Key and save it, or leave this tab open. You will need it in the next step.
-
If you changed any settings, click Save Changes.
Step 2: How to Add Your EZSSH SSH CA to GitHub
-
Go to GitHub and sign in with an account that is an owner of your organization.
-
On the top right, click your profile picture, and then click Your organizations.
-
Click Settings next to your organization.
-
In the left-hand menu, open your organization’s security settings (Organization security in the screenshot below, Authentication security in newer versions of GitHub).
-
Scroll down to SSH certificate authorities and click New CA.
-
Paste the CA Public Key you copied from EZSSH into the Key field and click Add CA.
-
Your EZSSH CA is now listed under SSH certificate authorities.
-
(recommended) Select Require SSH Certificates and click Save. This only allows git operations over SSH that use an SSH certificate. If you leave it disabled, your engineers can keep using their long-lived SSH keys, which defeats the purpose of short-lived certificates.
Done! Your GitHub organization now trusts the SSH certificates issued by EZSSH.
By default, EZSSH assumes that each user’s username in your identity provider matches their GitHub username. If they are different, your users cannot authenticate until you set up user mapping.
How to Map Your Entra ID Users to GitHub Users for SSH Certificates
GitHub only accepts an SSH certificate if it has a valid GitHub username in its principals. By default, EZSSH uses the user’s identity provider username. If your users have the same username in GitHub and in your identity provider, no additional configuration is needed. Otherwise, pick the mapping option that matches how your users are created in GitHub:
| How Your Users Are Created in GitHub | Mapping Option in EZSSH |
|---|---|
| GitHub Enterprise Cloud, where engineers link their personal GitHub account to your organization with SAML | SAML Mapping (Source GitHub) |
| GitHub Enterprise Managed Users (EMU) with SAML and no SCIM provisioning | SAML Mapping (Source GitHub) |
| GitHub Enterprise Managed Users (EMU) with SCIM provisioning | User Transformation (Source Entra ID) |
If you use SAML together with SCIM user provisioning, use User Transformation (Source Entra ID), because GitHub does not keep track of the mapping in that case.
How to Set Up SAML Mapping for GitHub SSH Certificates
With SAML mapping, EZSSH asks GitHub which GitHub username is linked to each SAML identity. To give EZSSH access to that information, you create a GitHub access token and add it to your EZSSH subscription.
How to Create a GitHub Access Token for SAML Mapping
EZSSH reads the mapping between your identity provider users and their GitHub usernames with a GitHub personal access token. Follow these steps to create one:
-
Go to GitHub (or your GitHub Enterprise instance) and sign in with an account that is an owner of the organization.
-
On the top right, click your profile picture, and then click Settings.
-
At the bottom of the left-hand menu, click Developer settings.
-
Select Personal access tokens > Tokens (classic).
-
Click Generate new token, and then select Generate new token (classic).
-
Enter a Note to identify the token, such as “EZSSH User Mapping”.
-
Select an Expiration for the token. We recommend 365 days. EZSSH stops mapping new users when the token expires, so set a reminder to replace it before then.
-
Select the following scopes:
read:orgread:useruser:emailread:enterprise(only for GitHub Enterprise Managed Users)
-
Click Generate token.
-
Copy your token and keep it somewhere safe. GitHub only shows it once, and you will need it in the next section.
-
If your organization uses single sign-on (SSO), click Configure SSO next to the token and authorize it for your organization with your SSO identity. Without this step, EZSSH cannot read your organization’s users.
How to Add the SAML Mapping Information to EZSSH
-
Go to the EZSSH portal and sign in with an account that is a Subscription Administrator of the subscription that issues your GitHub certificates.
-
From the left-hand menu, click Settings.
-
Find the subscription and expand Advanced Settings.
-
Under Map Entra ID Users to GitHub Users, select SAML Mapping (Source GitHub).
-
Enter your GitHub URL:
- GitHub Enterprise Cloud: Enter the URL of your organization in the format
https://github.com/orgName. - GitHub Enterprise Managed Users: Enter only the name of your enterprise, such as
keytosemu, not the full URL.
- GitHub Enterprise Cloud: Enter the URL of your organization in the format
-
Paste the token you created in the previous section into the GitHub Token field.
-
Click Test Connection.
Once you are done, save your settings:
-
Click Save Changes at the top of the Subscription Settings section. Your changes are not applied until you save them.
EZSSH now maps your users to their GitHub usernames at least once a day.
How to Set Up User Transformation for GitHub Enterprise Managed Users with SCIM
With SCIM provisioning, GitHub does not keep track of the mapping between your identity provider and GitHub. Instead, GitHub builds each username from the identity provider username plus a suffix for your enterprise. For example, if a user has the email sirtifficate@keytos.io in your identity provider, GitHub creates the username sirtifficate_keytos. EZSSH can apply the same transformation, so all you need is the suffix.
-
Go to the EZSSH portal.
-
From the left-hand menu, click Settings.
-
Find the subscription that has GitHub certificates enabled and expand Advanced Settings.
-
Under Map Entra ID Users to GitHub Users, select User Transformation (Source Entra ID).
-
Find the suffix that GitHub adds to your users. You can see it in the list of people in your GitHub enterprise. In our example, it is
_keytos.
-
Enter the suffix, including the underscore, in the User suffix field.
Once you are done, save your settings:
-
Click Save Changes at the top of the Subscription Settings section. Your changes are not applied until you save them.
How to Restrict the IP Addresses That Can Access GitHub with SSH Certificates
To further secure your GitHub organization, you can restrict the IP addresses that can use your GitHub SSH certificates. Even if a certificate is stolen, it cannot be used to access GitHub from an unauthorized location. We recommend adding the public IP addresses of your offices and VPN.
Once IP restrictions are enabled, GitHub SSH certificates only work from the IP addresses in the list. Engineers connecting from any other network, such as their home network without your VPN, cannot push or pull code.
-
Go to the EZSSH portal.
-
From the left-hand menu, click Settings.
-
Find the subscription that has GitHub certificates enabled and expand Advanced Settings.
-
Under Restrict GitHub IPs, select Add IP Restrictions to GitHub Certs.
-
In the Allowed IPs field, enter an IP address or CIDR block (for example
203.0.113.10or203.0.113.0/24) and click Add IP. You can enter multiple values as a comma-separated list.
Once you are done, save your settings:
-
Click Save Changes at the top of the Subscription Settings section. Your changes are not applied until you save them.
Next Steps - How to Access GitHub with EZSSH
Now that your GitHub organization trusts your EZSSH CA, your engineers can start requesting GitHub certificates with the EZSSH client.
🚀 Access GitHub with EZSSHIf something is not working, check out our guide to troubleshoot EZSSH issues with GitHub.