How-To: Set Up SSH Certificate Authentication in GitHub

Learn how to enable SSH certificate authentication for GitHub Enterprise with EZSSH, map your Entra ID users to GitHub usernames, and restrict GitHub access by IP address.

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

  1. You have registered the Keytos application in your Entra ID tenant.
  2. You have selected an EZSSH plan.
  3. 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

  1. Go to the EZSSH portal.

  2. From the left-hand menu, click Settings.

  3. Under GitHub access certificates, make sure GitHub certificates are enabled is selected for your subscription.

    EZSSH Agentless JIT Access Settings page showing Subscription Settings with the GitHub certificates are enabled checkbox highlighted
  4. 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.

    EZSSH Agentless JIT Access Settings page showing Subscription Settings with the GitHub Access Certificate Length field set to "8" highlighted
  5. Copy the CA Public Key and save it, or leave this tab open. You will need it in the next step.

    EZSSH Agentless JIT Access Settings page showing the CA Public Key field with the copy button highlighted to copy the SSH CA public key
  6. If you changed any settings, click Save Changes.

Step 2: How to Add Your EZSSH SSH CA to GitHub

  1. Go to GitHub and sign in with an account that is an owner of your organization.

  2. On the top right, click your profile picture, and then click Your organizations.

    GitHub profile menu showing the signed-in account options with Your organizations highlighted to open the organization list
  3. Click Settings next to your organization.

    GitHub Organizations list showing the markeytos organization with the Settings button highlighted
  4. In the left-hand menu, open your organization’s security settings (Organization security in the screenshot below, Authentication security in newer versions of GitHub).

    GitHub organization settings showing the Organization profile page with Organization security highlighted in the Account settings menu
  5. Scroll down to SSH certificate authorities and click New CA.

    GitHub Organization security page showing the SSH Certificate Authorities section with the New CA button highlighted
  6. Paste the CA Public Key you copied from EZSSH into the Key field and click Add CA.

    GitHub SSH Certificate Authorities Add new page with the EZSSH CA public key pasted in the Key field and the Add CA button highlighted
  7. Your EZSSH CA is now listed under SSH certificate authorities.

  8. (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.

    GitHub SSH Certificate Authorities list showing the added CA fingerprint with the Require SSH Certificates checkbox highlighted

Done! Your GitHub organization now trusts the SSH certificates issued by EZSSH.

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:

  1. Go to GitHub (or your GitHub Enterprise instance) and sign in with an account that is an owner of the organization.

  2. On the top right, click your profile picture, and then click Settings.

    GitHub Enterprise Dashboard with the profile menu open and Settings highlighted to open the personal account settings
  3. At the bottom of the left-hand menu, click Developer settings.

    GitHub Enterprise Managed User account Settings page showing the Public profile with Developer settings highlighted in the left menu
  4. Select Personal access tokens > Tokens (classic).

  5. Click Generate new token, and then select Generate new token (classic).

    GitHub Personal access tokens (classic) page showing no tokens created with the Generate new token button highlighted
  6. Enter a Note to identify the token, such as “EZSSH User Mapping”.

  7. 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.

    GitHub New personal access token (classic) page with the Note set to "EZSSH User Mapping" and a Custom Expiration date selected
  8. Select the following scopes:

    • read:org
    • read:user
    • user:email
    • read:enterprise (only for GitHub Enterprise Managed Users)
    GitHub personal access token Select scopes list with the read:org, read:user, and user:email scopes selected and highlighted
  9. Click Generate token.

  10. Copy your token and keep it somewhere safe. GitHub only shows it once, and you will need it in the next section.

  11. 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.

    GitHub Personal access tokens page showing a newly generated token with the Enable SSO button highlighted to authorize it for the organization

How to Add the SAML Mapping Information to EZSSH

  1. Go to the EZSSH portal and sign in with an account that is a Subscription Administrator of the subscription that issues your GitHub certificates.

  2. From the left-hand menu, click Settings.

  3. Find the subscription and expand Advanced Settings.

    EZSSH Agentless JIT Access Subscription Settings section with the Advance Settings expand arrow highlighted to show the advanced options
  4. Under Map Entra ID Users to GitHub Users, select SAML Mapping (Source GitHub).

    EZSSH Agentless JIT Access Advance Settings section showing the Map SAML Users to GitHub Users checkbox highlighted before it is selected
  5. 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.
    EZSSH Agentless JIT Access Advance Settings section with the GitHub URL field set to "https://github.com/keytos" highlighted
  6. Paste the token you created in the previous section into the GitHub Token field.

    EZSSH Agentless JIT Access Advance Settings section with the GitHub Token field filled in and highlighted next to the Test Connection button
  7. Click Test Connection.

    EZSSH Agentless JIT Access Advanced Settings with Map SAML Users to GitHub Users selected, GitHub URL "keytosemu", and Test Connection highlighted

Once you are done, save your settings:

  1. Click Save Changes at the top of the Subscription Settings section. Your changes are not applied until you save them.

    EZSSH Agentless JIT Access Settings page showing the Subscription Settings header with the Save Changes button highlighted

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.

  1. Go to the EZSSH portal.

  2. From the left-hand menu, click Settings.

  3. Find the subscription that has GitHub certificates enabled and expand Advanced Settings.

    EZSSH Agentless JIT Access Subscription Settings section with the Advance Settings expand arrow highlighted to show the advanced options
  4. Under Map Entra ID Users to GitHub Users, select User Transformation (Source Entra ID).

    EZSSH Agentless JIT Access Map Entra ID Users to GitHub Users options with User Transformation (Source Entra ID) selected and highlighted
  5. 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.

    GitHub enterprise People list for keytosemu showing managed user names with the "_keytos" suffix highlighted in each username
  6. Enter the suffix, including the underscore, in the User suffix field.

    EZSSH Agentless JIT Access Advanced Settings with User Transformation (Source Entra ID) selected and the Users Suffix field set to "_keytos" highlighted

Once you are done, save your settings:

  1. Click Save Changes at the top of the Subscription Settings section. Your changes are not applied until you save them.

    EZSSH Agentless JIT Access Settings page showing the Subscription Settings header with the Save Changes button highlighted

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.

  1. Go to the EZSSH portal.

  2. From the left-hand menu, click Settings.

  3. Find the subscription that has GitHub certificates enabled and expand Advanced Settings.

  4. Under Restrict GitHub IPs, select Add IP Restrictions to GitHub Certs.

    EZSSH Agentless JIT Access Advanced Settings showing Restrict GitHub IPs with the Add IP Restrictions to GitHub Certs checkbox highlighted
  5. In the Allowed IPs field, enter an IP address or CIDR block (for example 203.0.113.10 or 203.0.113.0/24) and click Add IP. You can enter multiple values as a comma-separated list.

    EZSSH Agentless JIT Access Advanced Settings showing the Allowed IPs list highlighted with the Add IP button and the IP "2.2.2.2" added

Once you are done, save your settings:

  1. Click Save Changes at the top of the Subscription Settings section. Your changes are not applied until you save them.

    EZSSH Agentless JIT Access Settings page showing the Subscription Settings header with the Save Changes button highlighted

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 EZSSH

If something is not working, check out our guide to troubleshoot EZSSH issues with GitHub.