# What precisely does --ssh do inside a docker-build?

**URL:** <https://forums.docker.com/t/what-precisely-does-ssh-do-inside-a-docker-build/108424>\
**Category:** General\
**Tags:** docker, build\
**Created:** [May 4, 2021, 10:23am UTC](https://forums.docker.com/t/what-precisely-does-ssh-do-inside-a-docker-build/108424 "2021-05-04T10:23:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![couling](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/couling/32/30104_2.png) [@couling](https://forums.docker.com/u/couling)\
**Post date:** [May 4, 2021, 10:23am UTC](https://forums.docker.com/t/what-precisely-does-ssh-do-inside-a-docker-build/108424/1 "2021-05-04T10:23:42Z")

</div>

I’m going round in circles trying to get buildkit to actually forward my SSH agent. I’ve tried various things with environment variable `DOCKER_BUILDKIT=1` and:

- `--ssh default`
- `--ssh $SSH_AUTH_SOCK`
- `--ssh /tmp/ssh-kMLMKuJKBj/agent.3964170`

And nothing seems to work. What’s curious is that when I run experimental commands inside the Dockerfile there’s no evidence of the agent actually being forwarded.

SSH\_AUTH\_SOCK is not set inside the build environment and `/tmp` is empty.

I’ve tried this on various installs of docker both on mac and ubuntu. Mostly version 19.03.6 API version 1.4.

What am I missing here?

---

<div class="post-metadata">

**Author:** ![couling](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/couling/32/30104_2.png) [@couling](https://forums.docker.com/u/couling)\
**Post date:** [May 4, 2021, 11:43am UTC](https://forums.docker.com/t/what-precisely-does-ssh-do-inside-a-docker-build/108424/2 "2021-05-04T11:43:57Z")

</div>

Okay this could be a little better documented on the docker-build page. Anyway if anyone else trips up on this, you need to explicitly use the agent in your docker file for this to work.

Instead of this:

```auto
RUN ssh ...

```

do this

```bash
RUN --mount=type=ssh ssh ...

```
