If you are not sure you have an SSH key already installed on your machine, you can do a quick check by issuing the following command. I am using GitBash to do so:
$ lsΒ -al ~/.ssh
If you don’t see the two files in the ssh folder in c:\Users\<userName>\ssh, then you don’t have the key created just yet! See image below:
What you need now is to generate a new SSH key which can be done by using the following command with parameters:
$ ssh-keygen -t rsa -b 4096 -C “myEmail@myDomain.com”
You’ll be prompted to enter the file name to save the key to. Just hit enter to keep the suggested default file name. Do the same for passphrase and hit enter twice until you see the image below:
You can also verify by going to the Users\yourName\ssh folder to confirm the files are created.
Next, you want to ensure that the ssh-agent is running. You can do so by issuing the following command:
$ eval $(ssh-agent -s)
Next, add your SSH private key to the ssh-agent
$ ssh -add ~/.ssh/id_rsa
Open the id_rsa.pub file in notepad and copy its contents to the clipboard. Note: There were two files created, i.e. id_rsa and id_rsa.pub. You want to open and copy the contentsΒ of id_rsa.pub file.
Now, go to your GitHub account. Under settings, locate the SSH and GPG keys tab and add the new SSH key from Notepad by clicking on the New SSH key button. See image below.
Finally, you can verify that your machine can communicate with GitHub by typing the following command:
$ ssh -T git@github.com
Hope you found the post useful!