Reputation: 237
I am using Sourcetree, and a repository configured via SSH and all operations work without a problem, but via Git Bash I am not able to perform a single fetch or pull:
git fetch
output: Permission denied (publickey).
fatal: Could not read from remote repository.
Is there a way to make Git to use this working Sourcetree configuration?
Upvotes: 2
Views: 1566
Reputation: 2302
I assume you are using Windows. You can use Git with either OpenSSH or Plink (PuTTY). When you use plink within Sourcetree, your SSH keys are read from PuTTY (e.g. pagent) or from what you configured withing Sourcetree, when you use Git Bash with OpenSSH on the other side they are read from ~/.ssh/id_whatever.
To fix it, use the same SSH technology in both clients. To change it in Sourcetree, go to preferences, and to change it in Git Bash, I think you need to re-install it. During the installation you are asked whether to use plink or OpenSSH.
Upvotes: 2
Reputation: 237
I finally found the solution:
Git Bash and Pageant are not using keys
Upvotes: 1
Reputation: 524
Generate an SSH key pair on your machine:
ssh-keygen -t rsa -C "[email protected]" -b 4096
Copy the public key to the repository:
cat ~/.ssh/id_rsa.pub
Running cat
will display the public key. You can also use SCP or something else to copy the public key over.
Upvotes: 0