Skip to content

✨ forward ssh-agent to build and run core operations #3581

Closed

Description

@grouville

What are you trying to do?

A user was trying to build, inside Dagger, a Dockerfile containing an advanced buildkit feature: mount=type=ssh (relying on llb.MountSSHSock)

This mount option tells the Docker frontend to forward the ssh connection of the ssh-agent to the build step and execute some ssh commands with the forwarded ssh connection. We do not support it for the build and run operations (for now).

It is really useful, as it works locally, and with password protected ssh keys:

  1. You load it locally: ssh-add yourkey
  2. You execute it
  3. It forwards the ssh to BuildKit

We are already relying on this feature for git:

if r.sshAuthSockID != "" {
opts = append(opts, llb.MountSSHSock(r.sshAuthSockID))
}

Why is this important to you?

A user requested it: https://discord.com/channels/707636530424053791/1034907314869780510/1034907314869780510.

It seems natural to be able to support this feature on our Container().Build(). I think it lies inside our core.build implementation.

However, the user was trying to build using the pants build tool, inside a docker.#Run (dagger v0.2)

image

How are you currently working around this?

The user managed to workaround it in Dagger v0.2 by forwarding the SSH_AUTH_SOCK.

However, I don't think it is possible in 0.3

Activity

  1. grouville commented on Oct 27, 2022

    @grouville
    MemberAuthor

    Even though it seems to be an easy fix, it might require some core.API design questions, if it gets optional: what does the option to forward the agent looks like in the core API

    P.S: if you feel it's an easy win, I'm not against implementing it (if possible 😇)

    cc @vito @sipsma @aluzzardi

  2. marcosnils commented on Nov 4, 2022

    @marcosnils
    Contributor

    , if it gets optional: what does the option to forward the agent looks like in the core API

    withMountedSSH maybe?

  3. Alvise88 commented on Nov 10, 2022

    @Alvise88
    Contributor

    This is quite useful for Dockerfile:

    RUN --mount=type=ssh go mod download
  4. added
    area/engine
    and removed on Dec 5, 2022
  5. sipsma commented on Dec 6, 2022

    @sipsma
    Contributor

    Unix socket mounting should enable this now: #4025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions