Forward SSH agent to container

I am using the SDK to start a container, and I need to forward the host’s SSH agent to the container.

How do I do this with the Go SDK? The primary deployment target for the Go app is a Mac for now, and I’m aware of some trickery with ssh-agent.

So far, I’m mounting SSH_AUTH_SOCK as such:

Mounts: []mount.Mount{
					Type:   mount.TypeBind,
					Source: "/run/host-services/ssh-auth.sock",
					Target: "/run/host-services/ssh-auth.sock",

However, it’s not forwarding SSH identities: ssh-add -L returns no identities.

SSH credentials are usually stored in a .ssh folder in every users home folder, so you would probably need to mount those, too.

Did you verify if ssh agent is running? also you can double check paths when mounting. Besides when creating GO container you can try to set the SSH_AUTH_SOCK Environment Variable: Within your container, you need to set the SSH_AUTH_SOCK environment variable to point to the mounted socket.

Yep, the agent is running; I’ve also set the SSH_AUTH_SOCK env var, which I’ve validated is set in the container.

I wonder if “/run/host-services/ssh-auth.sock” is not available outside docker desktop for Mac, and whether I need to do something different for the SDK?