# Can't get SSH auth working for private Github repos (using ssh-agent on Windows)

**URL:** <https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192>\
**Category:** General Usage\
**Tags:** pkg, github, ssh\
**Created:** [June 19, 2021, 6:32pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192 "2021-06-19T18:32:27Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [June 19, 2021, 6:32pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/1 "2021-06-19T18:32:27Z")

</div>

After months of nagging from Github I’m finally switching to SSH authentication. It’s working now for command line git operations (after I set the `GIT_SSH` environment variable to point to `ssh.exe`), but I can’t get it working for Pkg commands in Julia.

In other words, this works (i.e. completes without requesting passwords or SSH key locations):

```julia
> git clone git@github.com:niclasmattsson/MyPrivateRepo.git

```

But this one asks for the private key location, fails and pops up a window asking for my password:

```julia
(@v1.6) pkg> dev git@github.com:niclasmattsson/MyPrivateRepo.git
     Cloning git-repo `git@github.com:niclasmattsson/MyPrivateRepo.git`
Private key location for 'git@github.com' [C:\Users\niclas\.ssh\id_rsa]:

```

According to [this post](https://discourse.julialang.org/t/how-to-specify-the-ssh-key-for-pkg-to-use/14784/6), asking for the private key location doesn’t really mean that’s the problem, it’s just a generic SSH auth failure. I’ve also tried setting `SSH_KEY_PATH` and `SSH_PUB_KEY_PATH` as suggested there - that avoids the request for the private key location but still pops up the password prompt.

I’m on Windows 10, `ssh-agent` is running and works fine for git and remote-SSH inside VS Code to my work computer. My SSH key header is `-----BEGIN RSA PRIVATE KEY-----` which supposedly is the correct type for `libgit2`/`libssh2`.

---

<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:** [June 20, 2021, 1:07pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/2 "2021-06-20T13:07:16Z")

</div>

I don’t know what role `ssh-agent` plays in this as I’ve never used it, but plain ssh keys have been working fine for the windows users at work for some time now.

It’s still miserable to debug the problems though, so you may want to try your luck by being an early adopter of

> It is now possible to use an external `git` executable instead of the default libgit2 library for the downloads that happen via the Git protocol by setting the environment variable `JULIA_PKG_USE_CLI_GIT=true`.

from the Julia 1.7 `NEWS.md`. Julia 1.7 is presumably getting close to a beta release but for now you can try it out with a nightly build.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 20, 2021, 1:58pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/3 "2021-06-20T13:58:08Z")

</div>

That is curious: I access github repos with the https protocol and I don’t remember any nagging to change it.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 20, 2021, 2:11pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/4 "2021-06-20T14:11:29Z")

</div>

> [@PetrKryslUCSD](#):
>
> I don’t remember any nagging to change it.

Interesting. Right now, I have some repositories configured with HTTPS and other with SSH. Every time I use one with HTTPS protocol I get an e-mail from GitHub reminding me HTTPS support will be dropped.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 20, 2021, 2:15pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/5 "2021-06-20T14:15:37Z")

</div>

> [@Henrique\_Becker](#):
>
> e-mail from GitHub reminding me HTTPS support will be dropped.

Oh, damn. A tidal wave of work is heading my way, seems like…

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [June 20, 2021, 2:20pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/6 "2021-06-20T14:20:00Z")

</div>

Thank you Gunnar. I can’t find it right now, but when googling how to fix this problem yesterday I remember seeing a comment by Stefan from last year that he was working on having Pkg fallback to git if libgit2 fails. Or something to that effect - maybe I misunderstood and it was this environment variable option he was referring to. Anyway, great to see that functionality ready to roll out! Hearing about someone working on something one day and then the next day having it ready to test, it’s kind of like hopping into a time machine. 🙂

I think I’ll just live with having to enter a password for `]dev`ing a private repo with SSH until v1.7 comes out. I’ve also made some progress with HTTPS though, I’ll post that below.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 20, 2021, 2:20pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/7 "2021-06-20T14:20:24Z")

</div>

I can’t find any mention of this on github!?

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [June 20, 2021, 2:29pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/8 "2021-06-20T14:29:38Z")

</div>

This is the nag message I’ve been getting:

```nohighlight
Hi @niclasmattsson,

You recently used a password to access the repository at niclasmattsson/PrivateRepo with git using git/2.0 (libgit2 1.1.0).

Basic authentication using a password to Git is deprecated and will soon no longer work. Visit https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information around suggested workarounds and removal dates.

Thanks,
The GitHub Team

```

After updating Personal Access Tokens I temporarily lost the ability to authenticate via HTTPS, so I switched to SSH and posted here for help in getting those final details working. But it turns out that my HTTPS problems were apparently caused by an outdated version of Git for Windows. The latest version contained a new credential manager that authenticated via the browser, and now I can finally use HTTPS repos again without repeated password requests. Hopefully Github will stop nagging too, but that remains to be seen… 🙂

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [June 20, 2021, 2:30pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/9 "2021-06-20T14:30:39Z")

</div>

> <https://github.com/hub4j/github-api/issues/789>
>
> Github is dropping support for basic auth on Nov 13, 2020 (with service brownout…s on Sep 30 and Oct 28)
> https://developer.github.com/changes/2020-02-14-deprecating-password-auth/
> 
> We should make sure that we support using personal access tokens with the \`Authorization: token\` header. We may also want to issue deprecation warnings if users continue to use basic auth:
> https://github.com/github-api/github-api/blob/5c9474d1c891121f11ce9c31b51d42216a8e416f/src/main/java/org/kohsuke/github/GitHubClient.java#L119-L123

> **[Deprecating password authentication](https://developer.github.com/changes/2020-02-14-deprecating-password-auth/)**
>
> Get started with one of our guides, or jump straight into the API documentation.

---

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [June 20, 2021, 2:31pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/10 "2021-06-20T14:31:55Z")

</div>

I think I give you incorrect/imprecise information. GitHub is phasing out using manual authentication for git repository management ([Passwords begone: GitHub will ban them next year for authenticating Git operations • The Register](https://www.theregister.com/2020/12/17/github_bans_passwords/)). So I am not sure HTTPS support is being dropped, what I am sure it is being dropped is the SSH without keys (i.e., that you need to input user and password). Sorry for the noise.

---

<div class="post-metadata">

**Author:** ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Post date:** [June 20, 2021, 2:32pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/11 "2021-06-20T14:32:05Z")

</div>

Oh yeah, I switched to 2FA a while ago.

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [June 13, 2022, 7:18am UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/12 "2022-06-13T07:18:37Z")

</div>

I had the same problem with adding a remote repository on a private server using id\_ecdsa keys. I was about to give up when I found @GunnarFarneback’s useful answer. I wish this post had more visibility…

`JULIA_PKG_USE_CLI_GIT` is not documented in the manual version v1.7 but is in v.1.8.

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [June 13, 2022, 8:51am UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/13 "2022-06-13T08:51:11Z")

</div>

The only thing I can complain about it is that the encoding does not seem to be correct:

```julia
(@v1.8) pkg> dev --local DfRMTools
     Cloning git-repo `ssh://git@git.remote-server:7999/~michele.zaffalon/dfrmtools.jl.git`
←[?25h←[2K←[32m←[1m Resolving←[22m←[39m package versions...

```

---

<div class="post-metadata">

**Author:** ![NiclasMattsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/niclasmattsson/32/21988_2.png) [@NiclasMattsson](https://discourse.julialang.org/u/NiclasMattsson)\
**Post date:** [June 13, 2022, 12:12pm UTC](https://discourse.julialang.org/t/cant-get-ssh-auth-working-for-private-github-repos-using-ssh-agent-on-windows/63192/14 "2022-06-13T12:12:54Z")

</div>

Gunnar’s suggestion didn’t fix my issue last summer since I was on v1.6.x, but now with v1.7.3 out and v1.8 coming soon I’ll mark his post as the solution to help improve visibility.
