Setting up SSH Authentication for Github / GHES

So this is a small and quick post for me, and it’s one of those problems that you solve so infrequently that it just keeps coming up, and then you don’t remember how to do it.

Whether you are working in WSL, on a Linux VM, or even a windows VM. Authentication to github is a requirement for a lot of developers out there. And if you are using SSH keys to support the authentication, how do you handle creating a key pair, and setting up authentication.

The following are the steps:

  1. Setup git to have your profile information:
git config --global user.name "YOUR_USERNAME"
git config --global user.email "YOUR_EMAIL_ADDRESS"
  1. Open a terminal, and run the following command:
ssh-keygen -t rsa -b 4096 -C "YOUR_GITHUB_EMAIL_ADDRESS"

Now, a key note here is that I recommend you change the file name. This helps for consistency, and keeping things organized. For the sake of this, let’s name it “github.”

  1. Afterward, you can get the public key with the following:
cat ~/.ssh/github
  1. You can then take the value returned, and copy that value, and go to Github.com, and select your profile in the upper right hand corner. Select “Settings”, and then “SSH and PGP Keys”and paste the value in.

  2. You can then go back to your terminal and run the following:

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/ghes

You will then be prompted for your pass key, and can then authenticate with SSH to github.

Leave a Reply

Your email address will not be published. Required fields are marked *