Pkg.clone keeps asking for my SSH key


#1

Hello,

I am running Julia 0.7 on Ubuntu and when I try to clone a package, I get this problem:

julia> using Pkg

julia> Pkg.clone("git@github.com:eford/CORBITS.git")
┌ Warning: Pkg.clone is only kept for legacy CI script reasons, please use `add`
└ @ Pkg.API /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:445
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `git@github.com:eford/CORBITS.git`
Private key location for 'git@github.com': /home/duc299/.ssh/id_ed25519
Private key location for 'git@github.com' [/home/duc299/.ssh/id_ed25519]: /home/duc299/.ssh/id_ed25519
Private key location for 'git@github.com' [/home/duc299/.ssh/id_ed25519]: /home/duc299/.ssh/id_ed25519
ERROR: failed to clone from git@github.com:eford/CORBITS.git, error: GitError(Code:EAUTH, Class:Callback, Aborting, maximum number of prompts reached.)
Stacktrace:
 [1] pkgerror(::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:120
 [2] #clone#2(::Nothing, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::String, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/GitTools.jl:102
 [3] clone at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/GitTools.jl:83 [inlined]
 [4] (::getfield(Pkg.Types, Symbol("##25#28")){Pkg.Types.Context,Array{Pkg.Types.PackageSpec,1},String})(::LibGit2.CachedCredentials) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:533
 [5] shred!(::getfield(Pkg.Types, Symbol("##25#28")){Pkg.Types.Context,Array{Pkg.Types.PackageSpec,1},String}, ::LibGit2.CachedCredentials) at ./secretbuffer.jl:184
 [6] handle_repos_develop! at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Types.jl:498 [inlined]
 [7] #add_or_develop#13(::Symbol, ::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:52
 [8] #add_or_develop at ./none:0 [inlined]
 [9] #develop#19 at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:70 [inlined]
 [10] develop at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:70 [inlined]
 [11] macro expansion at ./logging.jl:310 [inlined]
 [12] clone(::String, ::String) at /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:445 (repeats 2 times)
 [13] top-level scope at none:0

So it keeps asking me for my SSH key and it won’t listen to me when I tell it where the SSH key is. Also, regular git seems to work fine:

~ % ls -ld .ssh
drwx------ 2 duc299 duc299 146 Sep 19 01:10 .ssh/
~ % 
~ % ls -l .ssh/id_ed25519*
-rw------- 1 duc299 duc299 411 Sep 19 00:59 .ssh/id_ed25519
-rw-r--r-- 1 duc299 duc299  98 Sep 19 00:59 .ssh/id_ed25519.pub
~ % 
~ % cd tmp
~/tmp % 
~/tmp % git clone git@github.com:eford/CORBITS.git
Cloning into 'CORBITS'...
Warning: Permanently added the RSA host key for IP address '192.30.253.112' to the list of known hosts.
remote: Counting objects: 405, done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 405 (delta 3), reused 13 (delta 3), pack-reused 389
Receiving objects: 100% (405/405), 85.34 KiB | 1.09 MiB/s, done.
Resolving deltas: 100% (210/210), done.

So the problem does not seem to be specifically with git. Also, the Pkg.clone line worked in two other computers. So I’m completely stuck. Why can’t Pkg.clone call git like on the command line? What’s missing?


#2

Are you using a .ssh/config file to specify your git key?
If so LibGit2 doesn’t read those.
But command line git does.

Both command line git, and LibGit2 do pay attention to your ssh-agent, if you have one running.

I’ve also heard there is an environment variable you can set to tell julia the path.


#3

No, I’m not using .ssh/config to specify the key. Git just seems to find it. It’s the only SSH key I have. And in any case, surely specifying a direct path to the key (like I did twice in the example I pasted) should tell LibGit2 where the key is.


#4

The man page for ssh-agent says:

ssh-agent is usually started in the beginning of an X-session or a login session

I am currently connecting remotely to the computer that’s not working. Could that be the problem? Hmm…

local_computer % echo $SSH_AGENT_PID
1414
local_computer % ssh remote_computer
...
remote_computer % echo $SSH_AGENT_PID

remote_computer %

It looks like I might have been using ssh-agent all along. Do you think ssh-agent will be working if I go physically to the remote computer? (it’s running an X session right now).


#5

Hmm… I do have ssh-agent running:

remote_computer ~/.ssh % ps x|grep ssh-agent       
16090 ?        Ss     0:00 ssh-agent
16118 ?        Ss     0:00 ssh-agent
16185 pts/5    S+     0:00 grep ssh-agent
27962 ?        S      0:00 /usr/bin/ssh-agent -D -a /run/user/710624/keyring/.ssh

So… why can’t LibGit2 see it?


#6

I found a magic incantation online. I don’t know what this does, but it worked:

~/.ssh % eval $(ssh-agent) > /dev/null
~/.ssh % ssh-add id_ed25519
~/.ssh % ssh-add -l
256 SHA256:GBqs+SzszuFd8PdgDo34UYzOVGSgIIQ6QuI6ecyJ4bA duc299@e1-052367 (ED25519)
...
julia> using Pkg

julia> Pkg.clone("git@github.com:eford/CORBITS.git")
┌ Warning: Pkg.clone is only kept for legacy CI script reasons, please use `add`
└ @ Pkg.API /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/API.jl:445
  Updating registry at `~/.julia/registries/General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
   Cloning git-repo `git@github.com:eford/CORBITS.git`
  Updating git-repo `git@github.com:eford/CORBITS.git`
[ Info: Assigning UUID 811cb5c5-b78b-5ed9-b25f-8f0cd4e719fe to CORBITS
 Resolving package versions...
  Updating `~/.julia/environments/v0.7/Project.toml`
  [811cb5c5] + CORBITS v0.0.0 [`~/.julia/dev/CORBITS`]
  Updating `~/.julia/environments/v0.7/Manifest.toml`
  [811cb5c5] + CORBITS v0.0.0 [`~/.julia/dev/CORBITS`]

So the immediate issue is resolved. It’d be good to not have to go through this, or at least understand what exactly I just did. Just running ssh-agent on the shell didn’t work. That “eval” bit seems to be required.


#7

Yes,
that is how ssh-agent words.
It isn’t nice, but it is how it works for everyone.

(I am not a fan of ssh-agent)


#8

Has anyone ever found any way to get this to use the keys properly? Is this a bug in LibGit2? It very much appears to be, as I have had this problem with multiple repos from multiple sources.