Setting up SSH tunnel with Github
SSH (Secure Shell) in Git and GitHub allows you to securely connect to your remote repositories, eliminating the need to enter your username and password every time you interact with them.
Benefits of using SSH:
Security: SSH uses public-key cryptography to authenticate your connection, making it much more secure than using HTTPS with a password.
Convenience: Once set up, you don't need to enter your credentials every time you push or pull code.
Signing commits: You can use your SSH key to sign commits, adding an extra layer of security and verifying your identity especially when you work with a distributed teams.
There are the steps to take to set up SSH keys with Github [Windows & macOS]
First — Why?
There are two main ways of working with repos using the terminal. One way is to HTTPs and another is to use SSH keys.
Once you set up using SSH keys you no longer need to enter a password every time you want to, for instance, clone a repository, pulling and pushing update. This speeds up your development workflow.
Another benefit is that using SSH keys is generally seen as being more secure than using passwords, because a bot can use a ‘brute force’ approach to try and guess your password.
Steps to take
Launch Git Bash [irrespective of Windows or macOS]
Navigate to .ssh folder
cd ~/.sshMake sure your .ssh folder is empty, if not then delete all existing files.
ls -al ~/.ssh
rm -i *Create ed25519 ssh key (avoid using RSA)
ssh-keygen -t ed25519 -C "<your github user email">Evaluate ssh-agent variable
eval "$(ssh-agent -s)"Add it to new file id_ed25519 i.e on your client machine add ***PRIVATE*** identity as ‘current’ private which you want to use
ssh-add ~/.ssh/id_ed25519At this point, .ssh folder must have only below file
ls -al ~/.ssh
.
..
id_ed25519
id_ed25519.pubUse the public key from id_ed25519.pub and create a new SSH KEY in your Github profile (This is mandatory before going to next step)
cat ~/.ssh/id_ed25519.pubEnsure your SSH Tunnel is properly setup correctly
ssh -T git@github.com
--> Hi <your github username>! You've successfully authenticated, but GitHub does not provide shell access.You are good to go and clone / pull / push the required Github repository!
Note: Instead of using the HTTPS URL to clone a repository, use the SSH URL
Like reading it, you can follow this newsletter.
Thank you so much for reading!
If you want to read my learnings on any specific topic, let me know in
the comment box. I will tag you too if I write on that.
xx



