If you want to be able to interact with your Git account without using passwords then you need to create an SSH key pair. You will then share the public key with GitHub to indicate to your repo that your computer is trusted. The first thing to do is to create the keys.
There are a couple of ways to do this on Windows, the easiest IMO is to use Git Bash.
Launch Git Bash and then enter the following command:
You will be prompted for the file name and location but the default will be shown to you, illustrated via the following example.
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Rick/.ssh/id_rsa):
Hit “Enter” to accept the default.
Next you will be asked for a password. You probably don’t want a password so that you can push to your Git repo without being asked to provide one. In that case, just hit “enter” and move on.
Below is an example showing the password step:
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Rick/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Next you will be asked to confirm the password – once you’ve confirmed it you will see a message indicating that both the private and public key were created:
Your public key has been saved in /c/Users/Rick/.ssh/id_rsa.pub.
The key fingerprint is:
a1:51:c2:b0:f2:9h:4c:1c:eb:a6:71:01:30:b3:db:82 test@test.com
$
Two key files have been created. Next you probably need to copy the public key to your clipboard. Enter the following command to view your Public Key:
Your key will appear within the Git Bash console – copy the key text starting with “ssh-rsa” and ending with your entire email address.
In Windows you won’t be able to simply highlight the text itself at first. Hit the “CTRL + a” key combination to select everything. This enables the ability to do a normal “click drag” text selection. Select your Public Key and hit “CTRL + c” to copy it.
From here…. you likely want to use it with your GitHub account.
Or, if you are using GitLab then follow these steps:
- Log into GitLab and navigate to the project.
- In the upper right-hand corner select the options icons (cog)
- Click the “SSH Keys” button in the left column
- Click the green “Add SSH Key” button
- Enter a Title
- Paste the public key into the key textarea
- Click “Add key”
If you need to see all of your public keys you can do the following: