So if you're like me chances are you've tried to set up a repository on GitHub once or twice and you must have encountered a number of issues. One such issue is GitHub asking for a username and password for every commit you make, this slows down workflow and can be really frustrating.
The reason this happens is that a lot of users interact with online repositories over the terminal using HTTP URLs which in itself is an awesome standard because it's straightforward and just works, However like every other thing there's always a "but" and in this case, it involves GitHub requesting for your login details for every push or pull request which can become frustrating over time.
Thankfully there's a protocol known as the Secure Shell (SSH) that makes connecting and authenticating remote servers and services(GitHub) a breeze. With SSH Keys connecting to services like GitHub is easy as you don't have to supply your credentials every time there is a need to login
In this article, I will be showing you how to connect to GitHub using SSH Keys. The very first thing is to check whether you actually have existing keys so as to avoid creating another one. Using your favourite terminal enter the following command to check if you have existing keys
ls -al ~/.ssh
And if you don't have any existing keys, you can create one using this command
ssh-keygen -t rsa -b 4096 -C "firstname.lastname@example.org"
This should you take you to the location you want to save the key, accept the default location by pressing enter. The next process involves entering a secure passphrase which is more or less an added security layer that makes sure your credentials are safe.
Once that is done the next step is to add your key to the SSH agent but before that, you have to ensure that the agent is running to check you can use the following command.
eval $(ssh-agent -s)
Now that you've got the SSH agent running the next thing is to add your key to the SSH agent this is done by
Having added your key to the SSH agent it's time to add the said key to your GitHub account but it has to be first of all copied. Once the command is entered it should display your SSH key, copy it.
After copying your SSH Key head to GitHub > Settings > SSH and GPG Keys. Click on Create A New SSH Key add a title say perhaps the name of the device you're using that particular key with e.g "Acer Swift 3" in the field assigned "Title" and paste your key in the field designated "Key". Hit Add SSH Key and GitHub should ask for your password and voila you're good to go.
Once you're done try pushing a new project to your GitHub, you should be able to make pull and push requests without GitHub asking for your password