How I linked my Kali Linux to my github account through SSH

allahisrabb

Abdussalam Mujeeb-ur-rahman

Posted on April 2, 2024

How I linked my Kali Linux to my github account through SSH

Linking your Kali Linux to your GitHub account through SSH can greatly streamline your workflow, allowing you to seamlessly push and pull code without the need to repeatedly enter your credentials.
By establishing this secure connection, you enhance both efficiency and security in managing your projects.

Me: In this article, I'll walk you through the simple steps I took in setting up SSH authentication between my Kali Linux system and my GitHub account.
Nobody: What of windows' users?.
Me: Windows' users can also follow my lead, but I will like them to use git bash as the command line.

Without further ado, let's jump into the game!.

Firstly, you need to generate an ssh key, and you can do that using the following command in your terminal:



ssh-keygen -t rsa -b 4096 -C your_email@example.com


Enter fullscreen mode Exit fullscreen mode

replace your_email@example.com with your email address (must be the one associated with your Github account).

Secondly, save the ssh key. By default, the ssh key files are saved in the ~.ssh directory. So, you can press enter to accept it or you can decide to change the location.
You will be prompted to enter and re-enter a passphrase which you can ignore by press enter immediately. Your key has been generated.

keygen

Thirdly, you need to add the new generated key to the ssh-agent (manages your ssh keys). So start the ssh-agent by running the command:



eval "$(ssh-agent -s)"


Enter fullscreen mode Exit fullscreen mode

Now, add your ssh private key to the ssh-agent by running the following command:



ssh-add .ssh/id_rsa 


Enter fullscreen mode Exit fullscreen mode

.ssh/id_rsa is the location of the private key from my current position in my terminal. Make sure you locate yours correctly.

Fourthly, Add the key to your github account.
Go to the .ssh folder, then locate and open id_rsa.pub in a text editor. Copy whatever is in there.
Now, let's paste it in our github.
Go to settings,
github settings

Go to SSH and GPG keys,
SSH and GPG keys

Click on New SSH Key button,
New SSH Key

Give it a title (example - Linux SSH key), The Key type is Authentication Key, paste what you copied in id_rsa.pub in the Key field.
Your result will be similar to this.
result

Now, let’s test the connection.
Run the following command in your terminal:



ssh -T git@github.com


Enter fullscreen mode Exit fullscreen mode

If everything is done correctly, you see a similar message:



Hi username! You've successfully authenticated, but GitHub does not provide shell access.


Enter fullscreen mode Exit fullscreen mode

But, some error like this might occur:
github error

You will need to get the private key and input it instead of typing yes when asked if you want to continue connecting.
To get the private key, you can run the command:



ssh-keygen -lf .ssh/id_rsa


Enter fullscreen mode Exit fullscreen mode

You will get something like



4096 SHA256:zjb3ddSf4AhvjyJdYDS4UqX+G0seY your_email.com (RSA)


Enter fullscreen mode Exit fullscreen mode

Copy everything except 4096 and (RSA). And that’s the private key.
And you're good to go.
success!

Now I am able to perform Git operations on repositories for which I am authorized.
git clone

Thanks.I hope it's helpful.

💖 💪 🙅 🚩
allahisrabb
Abdussalam Mujeeb-ur-rahman

Posted on April 2, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related