# What should I do when asked for a private key loaction when adding a private repository on windows

**URL:** <https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201>\
**Category:** New to Julia\
**Created:** [September 26, 2019, 2:12pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201 "2019-09-26T14:12:44Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![HBaghdadi1995](https://avatars.discourse-cdn.com/v4/letter/h/13edae/32.png) [@HBaghdadi1995](https://discourse.julialang.org/u/HBaghdadi1995)\
**Post date:** [September 26, 2019, 2:12pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/1 "2019-09-26T14:12:44Z")

</div>

When trying to add my private repository using the julia repl. It sops adding with a line saying `Private key location for 'git@github.com' [C:\Users\[username]\.ssh\id_rsa]:`

I’m not entirely sure what I should type in as it’s already pointing to the private key loaction. I’ve tried the following.

- Retyping in the private key location.
- Typing in the public key location.
- Typing in the directory tha contains both.  
But one of the above have allowed me to add my repository.

A few extra notes:

- The ssh key was given to github.
- The ssh key has been added to the agent.
- This is done on gitbash.
- I have looked at [this thread](https://discourse.julialang.org/t/pkg-clone-keeps-asking-for-my-ssh-key/15155/12) but couldn’t find a solution.
- The error I’m getting is `ERROR: failed to clone from git@github.com:[private repo].git, error: GitError(Code:ERROR, Class:SSH, Failed to authenticate SSH session: Unable to open public key file)`

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 26, 2019, 2:20pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/2 "2019-09-26T14:20:05Z")

</div>

I have been struggling with this issue for a long time. It still causes me a lot of pain.

On linux at least, it seems that the core problem is that _only_ the command line `ssh` uses `.ssh/config`, libgit2 does _not use it in any way_. I’m still not entirely sure why it won’t accept the key when I explicitly give it the location, but it seems like a moot point since one can’t do that in an automated fashion without some kind of config.

The only solution I am aware of is `ssh-agent`. That does work, but it is quite a pain to set up (if I had to do it again right now, I’d start by doing lots of duckduckgo searches).

I really wish there were some better solution, but at this point I don’t even know what that would be.

I’m afraid I have no idea what the situation is on Windows, but I’d imagine you’d still need to use `ssh-agent` or some Windows `ssh-agent` alternative.

---

<div class="post-metadata">

**Author:** ![oatlzzvztd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oatlzzvztd/32/3285_2.png) [@oatlzzvztd](https://discourse.julialang.org/u/oatlzzvztd)\
**Post date:** [September 26, 2019, 2:34pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/3 "2019-09-26T14:34:18Z")

</div>

The situation gets much worse when you have multiple, interdependent private repositories. I’ve just given up and enter my credentials several times for every update.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 26, 2019, 2:37pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/4 "2019-09-26T14:37:36Z")

</div>

My solution has been to manage repos with command line `git` and use `]dev`.

It works ok at first, but of course you can’t version control your packages. At some point I started writing increasingly elaborate Julia scripts to pull all my repos.

I feel like eventually I will just have wound up completely re-writing Pkg.jl with command line `git` as a back-end just to circumvent this issue.

---

<div class="post-metadata">

**Author:** ![oatlzzvztd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oatlzzvztd/32/3285_2.png) [@oatlzzvztd](https://discourse.julialang.org/u/oatlzzvztd)\
**Post date:** [September 26, 2019, 2:51pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/5 "2019-09-26T14:51:18Z")

</div>

Yeah, I used to recommend that. We started having problems with users accidentally committing Project.toml and Manifest.toml files with local paths still in them. Since I’m too lazy to figure out how to maintain a private registry, it’s also verbose to replace the local path with the remote.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [September 26, 2019, 3:07pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/6 "2019-09-26T15:07:50Z")

</div>

Could you test with Julia 1.3-RC2 and see if it makes a difference? [https://github.com/JuliaLang/julia/pull/33089](https://github.com/JuliaLang/julia/pull/33089) might make a difference.

---

<div class="post-metadata">

**Author:** ![HBaghdadi1995](https://avatars.discourse-cdn.com/v4/letter/h/13edae/32.png) [@HBaghdadi1995](https://discourse.julialang.org/u/HBaghdadi1995)\
**Post date:** [September 26, 2019, 3:18pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/7 "2019-09-26T15:18:13Z")

</div>

Hi, thank you both for your help.

@ExpandingMan  
I’ve been using an ssh-agent.  
I reactivated just in case it by running `$ eval $(ssh-agent)` and `ssh-add "C:\Users\[Username]\.ssh\id_rsa"`.  
This hasn’t done anything, it’s behaving the same way.  
You did mention having to perform many searches though, so were you thinking of using it another way?

@oatlzzvztd

> The situation gets much worse when you have multiple, interdependent private repositories. I’ve just given up and enter my credentials several times for every update.

This is exactly this situation I’m in!

@GunnarFarneback  
Unfortunatley that doesn’t seem to have fixed this.

FYI the error I’m getting is `ERROR: failed to clone from git@github.com:[private repo].git, error: GitError(Code:ERROR, Class:SSH, Failed to authenticate SSH session: Unable to open public key file)`

I’m going to added it to top post.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 26, 2019, 3:21pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/8 "2019-09-26T15:21:30Z")

</div>

> [@HBaghdadi1995](#):
>
> I’ve been using an ssh-agent.

I wish I could be more helpful, it’s been a while since I’ve tried to set it up. I remember it being a pain, but basically working as advertised. One of my major concerns with it was it screwing up my existing, perfectly cogent `.ssh/config` usage for other things. Nervousness over that has probably been my main motivation for not pursuing it further. I think @oxinabox was the one who told me he uses `ssh-agent`, maybe he can chime in.

> [@GunnarFarneback](#):
>
> Could you test with Julia 1.3-RC2 and see if it makes a difference?

Exactly the same behavior.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [September 26, 2019, 4:50pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/9 "2019-09-26T16:50:32Z")

</div>

I have no memory of how i set my SSH-Agent up.  
I just know I did, and that it works now.

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 26, 2019, 4:53pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/10 "2019-09-26T16:53:24Z")

</div>

For what it’s worth the [arch linux wiki entries](https://wiki.archlinux.org/index.php/SSH_keys#SSH_agents) for these things are always extremely informative, but in this particular case it doesn’t clear up any of my biggest concerns about how my normal ssh config will be affected.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [September 26, 2019, 6:01pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/11 "2019-09-26T18:01:12Z")

</div>

I use both so i think it is fine

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [September 26, 2019, 9:08pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/12 "2019-09-26T21:08:51Z")

</div>

For Windows, there is a _very_ simple solution:

```julia
git config --global credential.helper manager

```

and then use https git URLs for everything.

Here is the slightly more elaborate explanation 🙂

When you install standard git for windows, it also installs the [git credential manager for Windows](https://github.com/microsoft/Git-Credential-Manager-for-Windows). That credential manager essentially “just works” for things like github etc. with private repos. It supports two factor authentication and all the other good things.

When you run git command line, it will look in all the normal git config locations for a configuration setting for the credential helper (system, global and user, or whatever they are). BUT NONE of them have the config setting for the credential manager, _because_ there is yet another setting beyond system, global and user that _only_ applies to the git command line, and that is where the credential helper is configured to use `manager`.

Julia and libgit2 look in the system, global and user configuration for credential helper settings, but _not_ in this custom location for the git command line. And so by default, julia will _not_ pick up the `manager` setting for the credential helper, and so you won’t get the “good” credential helper where everything just works.

The command line I posted above configures the global `credential.helper` setting to use `manager`. That setting is picked up by the julia package manager, and then everything just works.

At least on my system 🙂

---

<div class="post-metadata">

**Author:** ![HBaghdadi1995](https://avatars.discourse-cdn.com/v4/letter/h/13edae/32.png) [@HBaghdadi1995](https://discourse.julialang.org/u/HBaghdadi1995)\
**Post date:** [September 27, 2019, 2:16pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/13 "2019-09-27T14:16:51Z")

</div>

Thanks, but I’m getting this error when I try downloading private repositories.

```julia
Value cannot be null.
Parameter name: Username
Parameter name: operationArguments
fatal: ArgumentException encountered.

```

---

<div class="post-metadata">

**Author:** ![amellnik](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amellnik/32/137_2.png) [@amellnik](https://discourse.julialang.org/u/amellnik)\
**Post date:** [September 27, 2019, 3:57pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/14 "2019-09-27T15:57:03Z")

</div>

I don’t remember how someone figured this out, but for users to interact with our internal package registry they need to run `ssh-add ~/.ssh/id_rsa` _from the shell prompt within julia_ (after uploading their public key to GitLab).

---

<div class="post-metadata">

**Author:** ![Christoph\_H](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christoph_h/32/8391_2.png) [@Christoph\_H](https://discourse.julialang.org/u/Christoph_H)\
**Post date:** [October 14, 2019, 9:21am UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/15 "2019-10-14T09:21:44Z")

</div>

I am still struggling with getting this to work on Windows 10 after trying lots of things. Among them adding the Environmental Variables for private and public key path and running ssh-add from within the julia shell prompt. Using https paths is quite annoying as it would change my setup on all computers/servers…

Is there a clean solution somewhere? Or a suggestion of where to look for errors in my setup?

---

<div class="post-metadata">

**Author:** ![Christoph\_H](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/christoph_h/32/8391_2.png) [@Christoph\_H](https://discourse.julialang.org/u/Christoph_H)\
**Post date:** [October 14, 2019, 9:30am UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/16 "2019-10-14T09:30:23Z")

</div>

I created a new ssh-key and it works. For some reason Julia did not accept the key, while git/powershell did…

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [October 14, 2019, 5:05pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/17 "2019-10-14T17:05:22Z")

</div>

> Thanks, but I’m getting this error when I try downloading private repositories.
> 
> ```julia
> Value cannot be null.
> Parameter name: Username
> Parameter name: operationArguments
> fatal: ArgumentException encountered.
> 
> ```

Yes, I’m also getting these, but they actually don’t seem to be fatal, everything then works just fine, so I just ignore those messages.

---

<div class="post-metadata">

**Author:** ![samuelpowell](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/samuelpowell/32/248_2.png) [@samuelpowell](https://discourse.julialang.org/u/samuelpowell)\
**Post date:** [December 11, 2019, 5:16pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/18 "2019-12-11T17:16:33Z")

</div>

This worked for me:

[https://github.com/JuliaLang/Pkg.jl/issues/911#issuecomment-515631128](https://github.com/JuliaLang/Pkg.jl/issues/911#issuecomment-515631128)

---

<div class="post-metadata">

**Author:** ![Zhong\_Pan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/zhong_pan/32/19872_2.png) [@Zhong\_Pan](https://discourse.julialang.org/u/Zhong_Pan)\
**Post date:** [January 28, 2020, 7:47pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/19 "2020-01-28T19:47:15Z")

</div>

This is my workaround in Windows 10: [https://discourse.julialang.org/t/help-pkg-add-from-companys-bitbucket-repository-fails-due-to-ssh-authentication/33897/3?u=zhong\_pan](https://discourse.julialang.org/t/help-pkg-add-from-companys-bitbucket-repository-fails-due-to-ssh-authentication/33897/3)

---

<div class="post-metadata">

**Author:** ![HBaghdadi1995](https://avatars.discourse-cdn.com/v4/letter/h/13edae/32.png) [@HBaghdadi1995](https://discourse.julialang.org/u/HBaghdadi1995)\
**Post date:** [February 25, 2020, 5:44pm UTC](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201/20 "2020-02-25T17:44:35Z")

</div>

Thank you very much Sam, this works.

[Next page](https://discourse.julialang.org/t/what-should-i-do-when-asked-for-a-private-key-loaction-when-adding-a-private-repository-on-windows/29201.md?page=2)
