#SSH agent forwarding
1 messages · Page 1 of 1 (latest)
👋 here's an example on how to accomplish this:
package main
import (
"context"
"os"
"dagger.io/dagger"
)
func main() {
ctx := context.Background()
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
panic(err)
}
defer client.Close()
sockPath := os.Getenv("SSH_AUTH_SOCK")
sshSock := client.Host().UnixSocket(sockPath)
_, err = client.Pipeline("ssh").
Container().
From("alpine").
WithExec([]string{"apk", "add", "openssh-client"}).
WithUnixSocket(sockPath, sshSock).
WithEnvVariable("SSH_AUTH_SOCK", sockPath).
WithExec([]string{"ssh", "-o", "StrictHostKeyChecking=accept-new", "git@github.com"}).
ExitCode(ctx)
if err != nil {
panic(err)
}
}
Thanks for your help @olive geode. Now I can forward SSH socket to the container.