Skip to content

Configuring SSH Authentication to GitHub

These optional one-time steps will guide you through configuring SSH authentication to github.com, which is more secure than passing credentials each time when using HTTPS. But if you prefer to clone the repository via HTTPS, you can skip this page and proceed to Cloning the Git repository.

NOTE: On Windows, the instructions found here will work best when using the Git Bash shell that is installed with Git for Windows. If you have not already installed that, go do it now and then return here.

Open a Git Bash terminal command prompt.

Determine whether you already have a certificate you can use:

Check existing files
ls -al ~/.ssh

Look for id_ed25519.pub (preferred) or id_rsa.pub (also supported). If you already have a key, you can move on to the "Copy the content" step below.

Create an ed25519 certificate and add it to your local SSH agent:

Create ed25519 certificate
ssh-keygen -t ed25519 -C "your.email@somedomain.com"
ssh-add ~/.ssh/id_ed25519

If ed25519 is not supported by your system, create an RSA certificate and add it to your local SSH agent:

Create RSA certificate
ssh-keygen -t rsa -b 4096 -C "your.email@somedomain.com"
ssh-add ~/.ssh/id_rsa

Copy the contents of your certificate's PUBLIC KEY (the file with the .pub extension) to the clipboard. Change the filename as necessary if you created an RSA certificate:

Display public key
cat ~/.ssh/id_ed25519.pub

IMPORTANT: Never share the private key (the contents of the file without the .pub extension).

Go to the SSH Keys section of your GitHub profile (if you are logged in to GitHub, you can get there directly by going to https://github.com/settings/keys), and then click the New SSH key button, enter a name for your key that identifies the system it's from, paste your public key data into the Key field, and click the Add SSH key button at the bottom of the page.

Back in the Git Bash window, you can test the SSH access:

Test SSH access
ssh -T git@github.com

You should see a message similar to this:

Sample output
Hi Your Name You've successfully authenticated, but GitHub does not provide shell access.

Having completed this process you can now clone repositories using the SSH mechanism instead of the HTTPS mechanism.