The guide is for windows 10 centric. The steps are 99% same for Linux/MacOS users as all the 3 OS can use gitbash, where the scripts are to be fired, but the only difference might be the commands that are being used. The underlying principles are same.
Using SSH, you don’t have to provide your username and password for each visit on github. These “visits” include git operations like: push, pull, fetch, clone, etc. You can use HTTPS method as well, but SSH is the way “real devs” handle git, and if you are here, reading this – you definitely are a “real dev”.
For Windows 10 users, open either
gitbash on your system.
Start your powershell with “Administrative” rights
Or you can start
gitbash, my personal favorite! Right click in the folder where you want to clone the repo (preferably) and select Git Bash Here
Next, paste the below script in your
ssh-keygen -t ed25519 -C "email@example.com"
Now, understanding the above script:
ssh-keygen generates a combo of personal and private encrypted SSH tokens. There are primarily two kinds of encryption algorithms used during SSH creation:
For a noob like you (and me), we just need to know that the ed25519 algorithm is better for now. If you are also cursed with the curiosity bug like me, then read about the differences here.
Next, select the location and the file name you want for your ssh key. Once you hit Enter on the key-generation script, you’ll see something like this, where
/c/Users/you/.ssh/ is the default location and
id_ed25519 is the default key name: both for public key (with
.pub extension) and for the private key.
Enter a file in which to save the key (/c/Users/you/.ssh/id_ed25519)
Ideally, do not change the location of the ssh-key. If you are using more than 1 ssh-keys/github account on the same machine, you can change the file name instead. For example, if I want to change the key name here, I’d have to give the complete path here:
Enter a file in which to save the key (/c/Users/you/.ssh/id_ed25519): /c/Users/you/.ssh/id_ed25519_my_custom_key
You’ll be asked to set a password for the key. This password will be used every-time you use the key. You can leave it blank if you are using this on a personal computer.
> Enter passphrase (empty for no passphrase): [Type a passphrase] > Enter same passphrase again: [Type passphrase again]
Once you pass that step, ssh-key will be generated with a combo of:
1. Public key – with
2. Private key – without any extention
A detailed guide is present here
In simple terms,
ssh-agent manages your ssh-keys. Keys are stored in an unencrypted manner and are used for protecting the keys and during ssh communication. Read more about ssh-agent here.
In windows, before you can add the ssh-key, you need to ensure that it is running. Run this in your git-bash
If you see something like
Agent pid 59566 then your ssh-agent is running in the background. Your agent pid can be different. No issues there!
Add your ssh-key
That’s it. They key is added!
The ssh-key with the
.pub extension is to be added to your GitHub Account. Copy your public ssh-key.
cat ~/.ssh/id_ed25519_my_custom_key.pub | clip
And paste it in your github profile’s settings page.
And paste the key in the “purple” area. Give a title to recognize the key!
Step 4: Enjoy!
That’s it. Now you can perform operations like clone, push, pull, fetch and many more without providing username and password repeatedly.
Thank you for reading. I hope you have a wonderful week ahead!
Feel free to reach out with suggestions and feedback. You can either email me or on the bird app (twitter) here.
For weekly updates on tech and such stuff, feel free to subscribe to my blog.