Setting up SSH Keys in Github

Posted by : at

Category : git

Ads by Google

Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username or password at each visit.

Setting up ssh keys in Github

For github

Open Terminal

Generating a SSH Key

Paste the text below, substituting in your GitHub email address.

$ ssh-keygen -t rsa -b 4096 -C "[email protected]"

This will create a public ssh key

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

Enter a file in which to save the key (/home/you/.ssh/id_rsa):

Enter the filename as yourusername-github (example: sujaykundu777-github)

At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".

Just press Enter twice”

Adding your SSH key to the ssh-agent

Start the ssh-agent in the background.

$ eval "$(ssh-agent -s)"

Add your SSH private key to the ssh-agent. If you created your key with a different name, in our case yourusername-github

$ ssh-add ~/.ssh/yourusername-github

The files - the private key and the public key should be inside the /home/yourusernme/.ssh folder.

Adding the ssh key to your Github Account

Copy the ssh key to your clipboard

$ sudo apt-get install xclip

Downloads and installs xclip. If you don’t have apt-get, you might need to use another installer (like yum)

$ xclip -sel clip < ~/.ssh/

Copies the contents of the file to your clipboard

Now paste this ssh key in Github settings page under settings > SSH and CPG Keys > Add SSH Key > Save SSH Key.Use a suitable title for the key.If prompted, confirm your GitHub password.

After saving the ssh key, just set the remote url using the ssh url provided for the repo:

$ git remote set-url origin [email protected]:yourname/yourrepo.git

That’s it, Now you don’t have to enter password everytime for a push

It should work, If you have any doubt or if something is not working for you, please leave a comment and I will help you as soon I read the comment.. Enjoy :D

Ads by Google