Help! Pkg.add from company's Bitbucket repository fails due to SSH authentication

@Pbellive Thank you for pointing me to the thread! After trying various combinations suggested by the replies and having a little “aha” moment of my own, I found the following workaround for Windows 10 with Julia 1.3.1:

(1) Regenerate the SSH key using the “-m PEM” option. In my case, the command line is:
ssh-keygen -t rsa -m PEM -C zpan@mycompany.com

Update the public key submitted to the private git server with the new key. Confirm that “git pull” can work.

(2) Create two system environmental variables:

SSH_KEY_PATH = C:/Users/zpan/.ssh/id_rsa
SSH_PUB_KEY_PATH = C:/Users/zpan/.ssh/id_rsa.pub

Alternatively, these also work:

SSH_KEY_PATH = C:\\Users\\zpan\\.ssh\\id_rsa
SSH_PUB_KEY_PATH = C:\\Users/zpan\\.ssh\\id_rsa.pub

Note the double backslash \\.

With these all set up, one can start a Julia session and add the package. There will be no prompt for the private key location and it would just work:

(v1.3) pkg> add ssh://git@bitbucket.mycompany.com:7999/opdt/mypackage.jl.git
  Updating registry at `C:\Users\zpan\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `ssh://git@bitbucket.mycompany.com:7999/opdt/mypackage.jl.git`
  Updating git-repo `ssh://git@bitbucket.mycompany.com:7999/opdt/mypackage.jl.git`
 Resolving package versions...
  Updating `C:\Users\zpan\.julia\environments\v1.3\Project.toml`
  [045fb6ed] + mypackage v0.1.0 #master (ssh://git@bitbucket.mycompany.com:7999/opdt/mypackage.jl.git)
  Updating `C:\Users\zpan\.julia\environments\v1.3\Manifest.toml`
  [045fb6ed] + mypackage v0.1.0 #master (ssh://git@bitbucket.mycompany.com:7999/opdt/mypackage.jl.git)

What didn’t work for me:

  1. Typing in the path or accepting default when Pkg.add prompts for the private key location. I tried every format to no avail.
  2. Using single backslash \ (e.g. C:\Users\zpan\.ssh\id_rsa), or using the drive letter without : (e.g. /C/Users/zpan/.ssh/id_rsa) in the environmental variables.

I will post link to this Windows workaround to the relevant threads, too.

7 Likes