4

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 .

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

Usually, I take a look from git GUI (in Windows). There is a menu about SSL (or SSH) and you can view the imported key.

1 Comment

Thanks , It is more with gitbash ,generally what happens ignore using forward slash while addind ssh key to this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.