Skip to content

Commit 056cb31

Browse files
ilopezlunaclaude
andcommitted
sandboxes: document opt-in SSH agent forwarding
SSH agent forwarding is no longer inherited implicitly from the daemon's environment. It requires explicit opt-in via ssh.agentForwardingEnabled, and each sandbox uses the client's SSH_AUTH_SOCK on create, start, or join, with ssh.agentSocketPath as an optional fixed override. Follows docker/sandboxes#5045. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 11100c7 commit 056cb31

3 files changed

Lines changed: 59 additions & 11 deletions

File tree

content/manuals/ai/sandboxes/security/credentials.md

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,11 +271,35 @@ interact with GitHub APIs on your behalf.
271271

272272
### SSH agent
273273

274-
If your host has an SSH agent and `SSH_AUTH_SOCK` is set, Docker Sandboxes
275-
forwards the agent into the sandbox and sets `SSH_AUTH_SOCK` there. The
276-
private keys stay on your host. Processes inside the sandbox can request
277-
signatures from the forwarded agent, but they can't read or copy the private
278-
key.
274+
SSH agent forwarding is disabled by default. To let sandboxes use your host
275+
SSH agent, enable it explicitly and restart the daemon:
276+
277+
```console
278+
$ sbx settings set ssh.agentForwardingEnabled true
279+
$ sbx daemon restart
280+
```
281+
282+
With forwarding enabled, Docker Sandboxes forwards your host agent into the
283+
sandbox and sets `SSH_AUTH_SOCK` there. The private keys stay on your host.
284+
Processes inside the sandbox can request signatures from the forwarded agent,
285+
but they can't read or copy the private key.
286+
287+
Each sandbox uses the `SSH_AUTH_SOCK` supplied by the client that creates,
288+
starts, or joins it. If a sandbox picks up the wrong agent, re-enter it from
289+
a shell where `SSH_AUTH_SOCK` points at the intended one.
290+
291+
To always forward a fixed socket instead — for example, the 1Password SSH
292+
agent — set `ssh.agentSocketPath`:
293+
294+
```console
295+
$ sbx settings set ssh.agentForwardingEnabled true
296+
$ sbx settings set ssh.agentSocketPath "$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
297+
$ sbx daemon restart
298+
```
299+
300+
When `ssh.agentSocketPath` is set, every sandbox uses that socket regardless
301+
of the client's `SSH_AUTH_SOCK`. Clearing the path switches back to the
302+
per-client socket; it doesn't disable forwarding.
279303

280304
Use SSH agent forwarding for Git operations over SSH and SSH-based commit
281305
signing. The signing key must be loaded in the host SSH agent for sandboxed

content/manuals/ai/sandboxes/troubleshooting.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,19 @@ the command again:
273273
Docker Sandboxes can sign Git commits with SSH keys from your host agent.
274274
For setup steps, see [Commit signing](workflows.md#commit-signing).
275275

276+
SSH agent forwarding is disabled by default. If `SSH_AUTH_SOCK` isn't set
277+
inside the sandbox, enable forwarding on the host and restart the daemon:
278+
279+
```console
280+
$ sbx settings set ssh.agentForwardingEnabled true
281+
$ sbx daemon restart
282+
```
283+
284+
Then re-enter the sandbox from a shell where `SSH_AUTH_SOCK` points at the
285+
agent that holds your keys. See
286+
[SSH agent](security/credentials.md#ssh-agent) for how the forwarded socket
287+
is selected.
288+
276289
If `ssh-add -L` prints `The agent has no identities.`, the sandbox can reach
277290
the forwarded agent, but the host agent doesn't have a loaded key. Load the
278291
signing key into your host SSH agent:

content/manuals/ai/sandboxes/workflows.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,18 +385,29 @@ $ curl http://host.docker.internal:11434
385385

386386
## Commit signing
387387

388-
Sandboxes forward your host SSH agent into the sandbox, so the agent can
389-
sign commits with your SSH key without the private key ever leaving your
390-
host.
388+
With SSH agent forwarding enabled, sandboxes forward your host SSH agent into
389+
the sandbox, so the agent can sign commits with your SSH key without the
390+
private key ever leaving your host.
391391

392-
1. On your host, make sure the signing key is loaded in your SSH agent:
392+
1. Enable SSH agent forwarding, which is disabled by default, and restart the
393+
daemon:
394+
395+
```console
396+
$ sbx settings set ssh.agentForwardingEnabled true
397+
$ sbx daemon restart
398+
```
399+
400+
For how the forwarded socket is selected, including using a fixed socket
401+
path, see [SSH agent](security/credentials.md#ssh-agent).
402+
403+
2. On your host, make sure the signing key is loaded in your SSH agent:
393404

394405
```console
395406
$ ssh-add ~/.ssh/id_ed25519
396407
$ ssh-add -L # confirm the key appears
397408
```
398409

399-
2. Inside the sandbox, configure Git to sign with SSH. Use the forwarded key
410+
3. Inside the sandbox, configure Git to sign with SSH. Use the forwarded key
400411
directly rather than a file path, since host paths don't exist inside the
401412
sandbox:
402413

@@ -405,7 +416,7 @@ host.
405416
$ git config --global user.signingkey "key::$(ssh-add -L | head -n 1)"
406417
```
407418

408-
3. Sign commits as usual:
419+
4. Sign commits as usual:
409420

410421
```console
411422
$ git commit -S -m "feat: my change"

0 commit comments

Comments
 (0)