In this blog, I am going to be teaching you exactly how you could add an SSH key to your GitHub which could prevent you from constantly typing in your email and password anytime you want to push to Github.
SSH key which stands for Secure Socket Shell or Secure Shell is just an access credential which resembles a password used to gain access to an encrypted connection between systems and and use that connection to manage a remote system.
- First thing you would need to do is to generate the public and private key which would be used for the connection between your computer and Github. Your private key is meant not to be shared. If something is to be shared here, that should probably be your public key as the name suggests.
- And to do this, run this command:
ssh-keygen -t rsa -b 4096 -C 'type your email here'
You would be asked the location to store the file. You can specify where you want it to be stored or press ENTER to store it in the default location.
Establish your passphrase which is nothing different from password. It adds to the security of your connection so it is good you set it up.
Press Enter after confirming your passphrase and you should see something like this.
- We need to add a key-manager which would hold our private keys for public keys authentication and would also save us some time typing our passphrase over and over again.
eval $(ssh-agent -s)
Now, we need to add the key-pair to the SSH.
Hit enter and enter the passphrase.
If you change your directory, you would need to specify that dir here also
Copy the public key to use in Github
clip < ~/.ssh/id_rsa.pub
If you couldn’t copy the key with your terminal, you can simply go the .pub file via the dir you saved the keys to. With what we have here, I will navigate to root dir and show all hidden files and dir. Go into the .ssh folder and open and copy the key in **id_rsa.pub**
- Open your Github and go to settings. (Top right corner by clicking on your avatar | image)
- On your left pane, you would find SSH and GPG key. Click on thin
- Add new SSH key
Fill in the title and paste the copied ssh key from your clipboard.
The title could be anything of your choice but should be a name that would easily identified.
You would be redirect to confirm the operation by entering your Github password.
You have now set up a secure and encrypted connection for data transfer between your computer and Github.