How to forward my SSH agent to a remote docker daemon?

Published

Accessing an SSH agent local to the docker daemon during build is a popular and well-documented use case. I need a remote docker daemon to access my local SSH agent. SSH agent forwarding generally provides remote access to a local agent.

But the remote builder insists that no SSH agent is running when I forward it and attempt to mount it in my Dockerfile:

$ cat ~/.ssh/config
Host <my-docker-daemon-host>
  ForwardAgent yes

$ ssh-add -l
256 SHA256:... ... (ED25519)

$ docker --version
Docker version 19.03.13, build 4484c46d9d

$ DOCKER_BUILDKIT=1 docker -H ssh://[email protected]<my-docker-daemon-host> build --ssh default .
[...]
#63 [test-image 33/51] RUN --mount=type=ssh ssh-add -l
#63 0.427 Error connecting to agent: No such file or directory
#63 ERROR: executor failed running [/bin/sh -c ssh-add -l]: runc did not terminate sucessfully

How can I direct the remote docker daemon to mount a forwarded SSH agent when executing RUN --mount=type=ssh in a Dockerfile?

Source: Docker Questions

Published
Categorised as docker, linux, ssh Tagged , ,

Answers

Leave a Reply

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq