#Cloning a git repository with SSH is failing

1 messages · Page 1 of 1 (latest)

tidal basin
#

I'm trying to follow this cookbook recipe to clone a private GitHub repository using an SSH key already available on my host.
https://docs.dagger.io/cookbook#clone-a-remote-git-repository-into-a-container-by-branch-tag-or-commit

I'm able to clone the repository from a terminal with git clone ... without issue.

However, when I replace the git repository URL in that cookbook example and try to run it I get the following error.

Error: failed to load cache key: NotFound: rpc error: code = NotFound desc = socket default not found: {"response":{"data":null,"errors":[{"message":"failed to load   
che key: NotFound: rpc error: code = NotFound desc = socket default not found","path":["container","from","withDirectory","terminal"]}],"status":200,"headers":{}},"r  
uest":{"query":"\n      { container  { from (address: \"alpine:latest\") { withDirectory (path: \"/src\",directory: \"ChV4eGgzOmIwODkyZDUwYjkwOWIyZDgSZQoVeHhoMzpiMDg  
mQ1MGI5MDliMmQ4EkwKFXh4aDM6ZDg2NTNkYTVhZWRmZGM3MRINCglEaXJlY3RvcnkYARoEdHJlZUoVeHhoMzpiMDg5MmQ1MGI5MDliMmQ4Ugd2MC4xNi4xEm0KFXh4aDM6ZDg2NTNkYTVhZWRmZGM3MRJUChV4eGgzOm  
NzRiN2M1M2RjYjQwZmISCgoGR2l0UmVmGAEaBmJyYW5jaCIQCgRuYW1lEgg6Bm1hc3RlckoVeHhoMzpkODY1M2RhNWFlZGZkYzcxEn4KFXh4aDM6ZjQ3NGI3YzUzZGNiNDBmYhJlEhEKDUdpdFJlcG9zaXRvcnkYARoDZ  
0IisKA3VybBIkOiJnaXRAZ2l0aHViLmNvbTpnaWZmZ2FmZi9jaGFydHMuZ2l0ShV4eGgzOmY0NzRiN2M1M2RjYjQwZmJSB3YwLjE2LjE=\") { terminal  { withWorkdir (path: \"/src\") { withExec (a  
s: [\"ls\",\"-lah\",\".\"]) { stdout  }}}}}} }\n    "}}                                                                                                                
Error: failed to load cache key: NotFound: rpc error: code = NotFound desc = socket default not found                                                                  
! process "tsx --no-deprecation --tsconfig /src/tsconfig.json /src/src/__dagger.entrypoint.ts" did not complete successfully: exit code: 1

Filesystem

tidal basin
wise frigate
#

@tidal basin do you have your SSH agent and your private key imported? sometimes git clone falls back to other strategies to fetch the credentials which is not the ssh agent

#

if you run ssh -T git@github.com does that work for you?

wise frigate
open phoenix
#

I am also running into this !? any resolution for this ?

#

Oki this is I think a documentation issue ...

wise frigate
#

happy to improve our docs about this. cc @abstract wing

open phoenix
#

I add comment on the BUG-report ... wasn't clear to my how ssh-add works / affects this ...

wise frigate
#

actually using ssh -T to test is not really accurate

#

as the ssh CLI looks for the private key in your .ssh folder to use them

open phoenix
#

yeah, that might be missleading yes ...

#

unfortunaluy this still fails though ?

func (m *Base) PublishImageFromGit(ctx context.Context) (string, error) {
repo := dag.Git(gitRepo)

var source *dagger.Directory
source = repo.Tag("4.5.1").Tree()
//source = repo.Tag("4.5.1").Tree().Directory("tooling")

// Print the directory structure for debugging
entries, err := source.Entries(ctx)
if err != nil {
    return "", err
}

fmt.Println(entries) // This should show all folders, including "tooling"

return m.PublishImage(ctx, source)

}

#

! failed to load cache key: NotFound: rpc error: code = NotFound desc = socket default not found

wise frigate
#

from where you're calling your dagger pipeline

#

and also ssh-add -l should list your corresponding private keys there

open phoenix
#

$ ssh-add /home/ubuntu/.ssh/manfred.nilsson@synkzone.com
Identity added: /home/ubuntu/.ssh/manfred.nilsson@synkzone.com (manfred.nilsson@synkzone.com)

#

is it because its ED25519 and not RS ?

#

RSA *

open phoenix
wise frigate
#

If you echo that variable it doesn't exist in your env?

open phoenix
#

$ eval "$(ssh-agent -s)" && ssh-add $HOME/.ssh/manfred.nilsson@synkzone.com && echo $SSH_AUTH_SOCK && ssh-add -l && dagger call publish-image-from-git
Agent pid 50082
Identity added: /home/ubuntu/.ssh/manfred.nilsson@synkzone.com (manfred.nilsson@synkzone.com)
/tmp/ssh-SWHDfD61U6Yu/agent.50081
256 SHA256:mT8Wvv7HvOwUKpSVxC4Z0XONXoS1S17WLkGSTw3jE/0 manfred.nilsson@synkzone.com (ED25519)
✔ connect 0.2s
✔ load module 0.6s
✔ parsing command line arguments 0.0s

✔ base: Base! 0.0s
✘ .publishImageFromGit: String! 0.3s
! failed to load cache key: NotFound: rpc error: code = NotFound desc = socket default not found
│ ✔ git(url: "git@git.synkzone.dev:Tooling/Base.git"): GitRepository! 0.0s
│ ✔ .branch(name: "master"): GitRef! 0.0s
│ ○ .tree: Directory! 0.1s
│ ✘ .entries: [String!]! 0.0s
│ ! failed to load cache key: NotFound: rpc error: code = NotFound desc = socket default not found

Setup tracing at https://dagger.cloud/traces/setup. To hide set DAGGER_NO_NAG=1

open phoenix
#

So how do I resolve this ? Any chance some one can point me in the right direction to debbug this ?

#

I am using Gitea, and it would real nice to be able to clone, pull, push , tag and commit

#

in a resonable easy way

#

this works ... but isa cludge

return dag.Container().
    //From("cgr.dev/chainguard/wolfi-base:latest").
    From("alpine:latest").
    WithExec([]string{"apk", "add", "git", "openssh-client", "ca-certificates", "bash"}).
    WithWorkdir("/src").
    WithUnixSocket(sockPath, sshAuthSock).
    WithEnvVariable("SSH_AUTH_SOCK", sockPath).
    WithEnvVariable("GIT_SSH_COMMAND", "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no").
    WithExec([]string{"sh", "-c", "git clone " + gitRepo + " && ls -la ./Base"}).Stdout(ctx)
wise frigate
#

I'm running a quick test

high anchor
#

hey, taking a look 👀

high anchor
high anchor
open phoenix
#

oh. yeah would be nice if it gets fixed ... I found this in Dagger verser also ... might want to look into stealing the test (with Gitea ) as I think it might be popular option for local git repos ... I would do it my self but I am not yet good enough to manage I am afraid

https://github.com/seungyeop-lee/daggerverse/tree/d582cc3d753317c638198c0a425b6bfb6d352793/private-git

GitHub

My Dagger modules. Contribute to seungyeop-lee/daggerverse development by creating an account on GitHub.

high anchor
#

Hey, it's not a regression but a security feature on our end: we prevent a module from accessing host sockets without users explicit consent.

We have isolated the root cause, coming up with a better error message / a repro and an alternative for you (directly on the issue)

wise frigate
high anchor
high anchor
wise frigate
#

We should document this better. cc @abstract wing

tidal basin
wise frigate
#

@tidal basin I see you're online. Have a sec to check this out?

high anchor
high anchor
#

Does it work for you @open phoenix ?

tidal basin
#

It's working now, but I had to recreate my SSH agent and re-add the key. Maybe the existing SSH auth sock managed by the Dev Container can't be used by Dagger.

wise frigate
#

having said that, I should work with the DevContainers ssh socket though 🤔

open phoenix
#

sry, yes I did get it to work .. but I am still passing in the key/file and doing a git clone inside ... since I want to do more with it ... IDK if it is the right way to do it or not .. I am only getting started with dagger ... what I am trying to do is run same local && ci .. including doing release .. so i would like to use SVN / SVU to generate the tags based on history and then also add tag etc etc ... shouldn't be anything strange I think ? how are other doing it ?