Using the SSH protocol, you can connect and authenticate to remote servers and services. With SSH keys, you can connect to GitHub without supplying your username and personal access token at each visit. SSH keys are preferred over password authentication and are easy to use once set up.
Check out the official [GitHub docs about SSH key generation]https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent.
-
Open Git-Bash
-
Paste the text below, substituting in your GitHub email address
$ ssh-keygen -t ed25519 -C "[email protected]"
-
When you're prompted to "Enter a file in which to save the key," press Enter. This accepts the default file location.
> Enter a file in which to save the key (/c/Users/you/.ssh/id_algorithm):[Press enter]
-
At the prompt, type a secure passphrase.(can be left empty)
> Enter passphrase (empty for no passphrase): [Type a passphrase]
> Enter same passphrase again: [Type passphrase again]
-
Ensure the ssh-agent is running
$ eval "$(ssh-agent -s)"
-
Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_ed25519 in the command with the name of your private key file.
$ ssh-add ~/.ssh/id_ed25519
-
Go to your github settings. Click on your icon->settings
-
Go to Access/ SSH and GPG keys
-
Get your public key from git bash.(copy all of it)
cat ~/.ssh/id_ed25519
-
Add the public key to your account with new SSH key