# Pkg: private repository usage and keys

**URL:** <https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575>\
**Category:** General Usage\
**Tags:** pkg\
**Created:** [September 27, 2018, 5:05pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575 "2018-09-27T17:05:36Z")\
**Posts on this page:** 16\
**Page:** 2

<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:** [October 29, 2018, 7:51pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/21 "2018-10-29T19:51:00Z")

</div>

> [@Tero\_Frondelius](#):
>
> Yes exactly and after setting the path to Git for Windows bin the problem disappeared mystically.

Hm… I know that Windows has some weird git installation, so it’s possible that `libgit` and `git` are linked somehow, I’m not sure.

---

<div class="post-metadata">

**Author:** ![chakravala](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chakravala/32/6832_2.png) [@chakravala](https://discourse.julialang.org/u/chakravala)\
**Post date:** [October 30, 2018, 10:12am UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/22 "2018-10-30T10:12:29Z")

</div>

> [@ExpandingMan](#):
>
> Does anyone know of any way I can get it to put them in there automatically so that I can instantiate in a build script with no user interaction?

> **[Caching your GitHub credentials in Git - GitHub Docs](https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git)**
>
> If you're cloning GitHub repositories using HTTPS, we recommend you use GitHub CLI or Git Credential Manager (GCM) to remember your credentials.

---

<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:** [October 30, 2018, 1:24pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/23 "2018-10-30T13:24:14Z")

</div>

I’m not sure this will really work as I’m trying to build in a docker, but thanks I’m sure it’ll be helpful for something at some point.

I think my real problem is that I’m trying to do a completely automated docker build, so even though I can use the credential helper during normal circumstances I’m not sure I can us it during the build process.

I think the best of bad options is going to be simply including everything that’s needed in the docker build directly. We are upgrading out git, at that point I’ll probably just tell IT that they have to fix the pull issues because it’s getting in the way of me doing my job.

---

<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:** [December 2, 2019, 11:06pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/24 "2019-12-02T23:06:15Z")

</div>

Possibly related and some debugging hints: [https://github.com/JuliaLang/Pkg.jl/issues/1516#issuecomment-560794389](https://github.com/JuliaLang/Pkg.jl/issues/1516#issuecomment-560794389)

---

<div class="post-metadata">

**Author:** ![euthoff](https://avatars.discourse-cdn.com/v4/letter/e/8e7dd6/32.png) [@euthoff](https://discourse.julialang.org/u/euthoff)\
**Post date:** [December 25, 2019, 4:41am UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/25 "2019-12-25T04:41:24Z")

</div>

Had this same issue, but on macOS Catalina. I needed to add my identity with ssh-add. From bash enter:

```julia
eval $(ssh-agent)
ssh-add

```

Then restart Julia. After this I was able to clone no problem!

---

<div class="post-metadata">

**Author:** ![OliverEvans96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliverevans96/32/4177_2.png) [@OliverEvans96](https://discourse.julialang.org/u/OliverEvans96)\
**Post date:** [February 19, 2021, 10:17pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/26 "2021-02-19T22:17:15Z")

</div>

I can confirm, I was having the same issue as @ExpandingMan , but @euthoff’s solution works for me on Julia v1.6.0-beta1. Can someone explain what’s going on? This definitely seems like a Pkg bug - I’ve never had to do anything like this with any other package manager.

---

<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:** [February 20, 2021, 11:58am UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/27 "2021-02-20T11:58:05Z")

</div>

Hard to say what exactly is your problem but I’ve documented the best practice I know for ssh keys at [https://github.com/GunnarFarneback/LocalRegistry.jl/blob/master/docs/ssh\_keys.md#3-generating-a-compatible-key](https://github.com/GunnarFarneback/LocalRegistry.jl/blob/master/docs/ssh_keys.md#3-generating-a-compatible-key).

---

<div class="post-metadata">

**Author:** ![OliverEvans96](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oliverevans96/32/4177_2.png) [@OliverEvans96](https://discourse.julialang.org/u/OliverEvans96)\
**Post date:** [February 20, 2021, 3:28pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/28 "2021-02-20T15:28:13Z")

</div>

Thanks for this @GunnarFarneback. As you point out, apparently using the PEM SSH key format works, but not the default OPENSSH format (which I was using) because (quoting you)

> `LibGit2` gets its ssh functionality from `libssh2` , which indeed is less capable of taking the `~/.ssh` configurations into account than the `ssh` command line interface used by the `git` command line interface.

But it seems like @StefanKarpinski is [working on improving this](https://discourse.julialang.org/t/pkg-fails-to-clone-with-ssh/39524/9).

Apparently the above solution involving `ssh-agent` somehow makes incompatible keys available to `libssh2` via an intermediary.

Just thought that summarizing the situation might be helpful for the next confused googler.

---

<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:** [February 20, 2021, 4:00pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/29 "2021-02-20T16:00:31Z")

</div>

In general not using ssh-agent is a world of pain.  
And that is sad.  
[https://github.com/JuliaLang/Pkg.jl/issues/911#issuecomment-769898970](https://github.com/JuliaLang/Pkg.jl/issues/911#issuecomment-769898970)

---

<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:** [February 20, 2021, 5:33pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/30 "2021-02-20T17:33:54Z")

</div>

For what it’s worth I’ve never used ssh-agent and plain keys have worked fine at work for a long time now. (Also we’re running a package server for our internal packages these days, so the need to use ssh for packages is marginal.)

---

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [April 6, 2025, 12:04pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/31 "2025-04-06T12:04:58Z")

</div>

I have the same issue: my private keys are used correctly everywhere EXCEPT when adding a custom registry. Have you ever found the solution for this?

The best I’ve been able to do so far is doing `registry add https://...` instead of `registry add git@....`. This works correctly, but it’s annoying to get asked for username/password every time julia hits the registry.

---

<div class="post-metadata">

**Author:** ![freeman](https://avatars.discourse-cdn.com/v4/letter/f/ec9cab/32.png) [@freeman](https://discourse.julialang.org/u/freeman)\
**Post date:** [April 6, 2025, 12:13pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/32 "2025-04-06T12:13:35Z")

</div>

Ok, based on this [1] I found a hack around.

Launch your julia like this:

```julia
JULIA_PKG_USE_CLI_GIT=true julia

```

Then this should work, at least this worked for me:

```julia
] registry add git@...

```

[1] [stop using libgit2 · Issue #2679 · JuliaLang/Pkg.jl · GitHub](https://github.com/JuliaLang/Pkg.jl/issues/2679)

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 18, 2025, 5:10pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/33 "2025-04-18T17:10:06Z")

</div>

Not really a hack, that’s the official way to do this.

---

<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:** [April 18, 2025, 5:18pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/34 "2025-04-18T17:18:13Z")

</div>

Fun fact: [jujutsu](https://github.com/jj-vcs/jj), the best VCS, recently changed to using CLI git by default I think because of exactly this issue.

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [April 18, 2025, 6:55pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/35 "2025-04-18T18:55:53Z")

</div>

Libgit2 is not great on the client side, unfortunately.

---

<div class="post-metadata">

**Author:** ![mappy](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mappy/32/217943_2.png) [@mappy](https://discourse.julialang.org/u/mappy)\
**Post date:** [July 27, 2025, 8:37pm UTC](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575/36 "2025-07-27T20:37:47Z")

</div>

Thankyou for saving me so much pain

[Previous page](https://discourse.julialang.org/t/pkg-private-repository-usage-and-keys/15575.md?page=1)
