Github uses SSH for authentication only. It is important to understand that it doesn’t use SSH for encrypting data back and forth.

  1. Download the entire git for windows package here. I choose the ‘Use windows CMD for the emulator’ option during the installation. If installed correctly, your ENV path variable should be setup – so typing ‘git’ in a command prompt should work.
  2. From a CMD prompt, create an SSH key pair using an email address (ideally your GitHub email address, if you plan to use this key pair for github). If you plan to just generate a key pair that is NOT to be used for github, you can use any email address. The email address just serves as a label for the key pair.
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

This creates a new ssh key pair.

3.  When you’re prompted to “Enter a file in which to save the key,” press Enter. .

4. Enter a file to save the key (defaults to  –  /c/Users/you/.ssh/id_rsa):[Press enter]
(If you do not have a .ssh folder, open up a powershell prompt and mkdir .ssh )

Note that the public key starts with ssh-rsa – and has your email at the end

$ cat .ssh/id_rsa.pub
ssh-rsa AAAA[........] johndoe@gmail.com

Add your key to the SSH agent (this is the client)

  1. Check that the agent is running  –
    $ eval $(ssh-agent -s) // should return pid of the process
  2. Add your private key to the SSH agent
    $ ssh-add ~/.ssh/id_rsa  // private key is the one without the .pub extension
    
    

3. Lastly, now that your private key is part of the agent (the client), your public key needs to be known to github (the server). To add your public key (ends in .pub) to your github account, follow these steps.

Summary

That’s it. This should be all that you need to get SSH based authentication working for github access. Generate an SSH key pair (using ssh-keygen part of gihub download), use the private key in your client agent, use the public key in the server github account – and you should be set. This avoids the headache of typing a username  and password for github authentication.

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.