Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add ssh key in git bash?

Tags:

ssh

To add key in Gitbash Make sure to use to enable ssh agent first.

eval $(ssh-agent -s)

[enter image description here][1] Now you can add ssh key in git bash using below command.

if you are doing it in windows Git Bash.

ssh-add /c/keyname

How to check if the key is added.

ssh-add -L

you should see the ssh key added here .

like image 898
Nirpendra Avatar asked Sep 20 '25 12:09

Nirpendra


1 Answers

Below are the steps:

  1. Open Git Bash and run below command on command prompt to generate public-private key pair ssh-keygen -t rsa -b 4096 -C "[email protected]"

  2. When you are 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/username/.ssh/id_rsa):[Press enter]

  3. At the prompt, type a secure passphrase. You can press enter if you want to leave it blank but its not recommended.

    Enter passphrase (empty for no passphrase): [Type a passphrase]
    Enter same passphrase again: [Type passphrase again]

  4. Go to /c/Users/username/.ssh/ folder and open id_rsa.pub file and copy entire contents of it.

  5. Finally, go to Github -> Settings -> SSH And GPG keys -> Click New RSA (Green Button). Give some meaningful title to the key and paste the public key copied in step 4 above. Now click on Add SSH Key button.

Congrats, you have added public key to github successfully and now you can use gitbash to access github repositories.

like image 103
sapan prajapati Avatar answered Sep 23 '25 10:09

sapan prajapati