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
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.
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)"
Now, add your ssh private key to the ssh-agent by running the following command:
ssh-add .ssh/id_rsa
.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,
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.
Now, let’s test the connection.
Run the following command in your terminal:
ssh -T git@github.com
If everything is done correctly, you see a similar message:
Hi username! You've successfully authenticated, but GitHub does not provide shell access.
But, some error like this might occur:
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
You will get something like
4096 SHA256:zjb3ddSf4AhvjyJdYDS4UqX+G0seY your_email.com (RSA)
Copy everything except 4096 and (RSA). And that’s the private key.
And you're good to go.
Now I am able to perform Git operations on repositories for which I am authorized.
Thanks.I hope it's helpful.
Top comments (0)