1

I have generated a pair of keys on my windows local machine.
I have a folder c:/users/me/.ssh containing :

  1. the private key
  2. the public key
  3. the known_hosts file

I have uploaded the public key to my github profile.

When I open a powershell terminal and run any git command to interact with my repository, like :

git fetch my_repo_name

everything is working well.

The problem is that, I do not want to use the default private key located in the default .ssh folder, and I want to be able to specify my private key, but when I run the following command :

ssh-agent $(ssh-add C:/Users/Me/Pictures/id_rsa; git fetch my_repo_name)

I get the following error :

Identity added: C:/Users/Me/Pictures/id_rsa (C:/Users/Me/Pictures/id_rsa)
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

ps : the pictures folder is just used for the example, the point is that I want to be able to use a specific located private ssh key other than the default one.

bssyy78
  • 319
  • 5
  • 16
  • 1
    Does this answer your question? [configure Git to accept a particular self-signed server certificate for a particular https remote](https://stackoverflow.com/questions/9072376/configure-git-to-accept-a-particular-self-signed-server-certificate-for-a-partic) Specifically, try setting `http.sslCAInfo`. You can find other, related Git config options [here](https://git-scm.com/docs/git-config). – paulsm4 Dec 05 '19 at 19:38
  • 1
    I would use one of the solutions here: https://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use – fredrik Dec 05 '19 at 19:39
  • 1
    @paulsm4 he is not having CA issues for HTTPS. He's having SSH issues. – fredrik Dec 05 '19 at 19:43
  • 2
    Does this answer your question? [Configure Git to use a .pem key from a specific location](https://stackoverflow.com/questions/30972776/configure-git-to-use-a-pem-key-from-a-specific-location) – phd Dec 05 '19 at 20:42
  • 1
    https://stackoverflow.com/search?q=%5Bgit%5D+%5Bssh%5D+use+specific+key – phd Dec 05 '19 at 20:42
  • 2
    You can configure different keys at the ssh level or git level. At the git level define `GIT_SSH` environment variable or `core.sshCommand` config var. – phd Dec 05 '19 at 20:44
  • 1
    @fredrik - there might be multiple different solutions. I believe there's a Git solution ... and, in this case, I believe that would be the preferred solution. In my response, I also linked to [git-config](https://git-scm.com/docs/git-config), which has several different certificate-related options. – paulsm4 Dec 05 '19 at 23:45

0 Answers0