How To Access A Git Repository Using SSH

July 12, 2022 . 2 MIN READ

Setting up SSH key with GitHub for Ubuntu

SSH stands for Secure Shell. SSH is a way to securely communicate with a remote computer. SSH is used for executing commands remotely by interacting with another system’s operating shell.

Using SSH, you can connect with GitHub without supplying your username and personal access token in each visit.

Prerequisites

Step 1: Generating a new SSH key

Open your terminal and use the following line to create a new SSH key.

ssh-keygen -t rsa -b 4096 -C "email@gmail.com"

In the place of email@gmail.com , enter the mail to which your GitHub account is linked.

Press Enter to save the key in the default location.

Step 2: Enter the passphrase

To add an extra layer of security, you can add a passphrase to your SSH key.
You can add the passphrase and save it on ssh-agent. If you don’t want to add it just proceed to the next step by pressing Enter twice.

Step 3: Adding your SSH key to ssh-agent

We can add our key using the following line

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_rsa

Step 4: Add your key to GitHub

In order to get our key, use the following command

cat ~/.ssh/id_rsa.pub

Then copy the content (starting from ssh-rsa). Now open your GitHub account and do the following steps :

You have successfully added a new SSH key to your GitHub account. Hope you found it useful.

Keep Exploring!!!

Reference:

https://link.medium.com/HS8oZINfwrb

https://askubuntu.com/questions/527551/how-to-access-a-git-repository-using-ssh

https://www.freecodecamp.org/news/git-ssh-how-to/

Leave a Reply

Your email address will not be published. Required fields are marked *