Hello.

til

Sign git commits in an Apple container with the 1Password agent

2026-11-20

TL;DR container run --ssh forwards whatever agent the host's SSH_AUTH_SOCK points to, and in my shell that is the macOS launchd agent, not the 1Password one. Set SSH_AUTH_SOCK to the 1Password socket for that one command and git signs commits inside the container.

With --ssh alone, the commit inside the container failed with No private key found. With the 1Password socket the container saw the keys and the commit had signature status G, a good signature.

The forwarded agent is the host's SSH_AUTH_SOCK

I run all npm work, git hooks included, in an Apple container, and I sign commits with the 1Password SSH agent. The flag --ssh ("Forward SSH agent socket to container") forwards the host's socket, so the shell's SSH_AUTH_SOCK decides which agent the container gets.

Default agent, then the 1Password socket
$ container run --rm --ssh ... node:24-bookworm sh run.sh
error: No private key found for "/tmp/.git_signing_key_tmpLZmP7P"?

fatal: failed to write commit object
$ SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" container run --rm --ssh ... node:24-bookworm sh run.sh
7
G

The ... stands for the flags that pass the public key and mount run.sh. run.sh counts the agent's keys with ssh-add -L | wc -l, commits, then prints git log --format=%G? -1. The socket path is the macOS one from the 1Password docs. The container already has git and ssh-keygen (image node:24-bookworm), and it reaches the agent at /var/host-services/ssh-auth.sock.

Inside the container, git uses gpg.format=ssh, user.signingkey="key::<public-key>" and commit.gpgsign=true. Leave gpg.ssh.program unset: 1Password's op-ssh-sign is a macOS binary, and the default ssh-keygen signs through the agent.

Try it yourself

Paste this into Claude Code to set up signing on the host and the --ssh wrapper. It builds on 1Password's commit signing guide, except that it sets user.signingkey in the key::<public-key> form that ran here, and it asks before it changes your config.

Set up signing and container agent forwarding

Set up git commit signing with the 1Password SSH agent on this Mac, then make Apple `container` use that same agent. Reference: https://www.1password.dev/ssh/git-commit-signing/

1. Check first, change nothing yet. Print `git config --global --list --show-origin | grep -Ei 'gpg|sign'`. Find the 1Password agent socket (macOS: ~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock) and run `SSH_AUTH_SOCK=<that socket> ssh-add -L`. If it lists no keys, stop and tell me to turn on the SSH agent in 1Password and add a signing key.
2. Ask me which key to sign with and which email to use. Then show me the exact global config you plan to set and wait for my yes before writing it: gpg.format=ssh, user.signingkey="key::<public-key>", commit.gpgsign=true, gpg.ssh.program=/Applications/1Password.app/Contents/MacOS/op-ssh-sign, gpg.ssh.allowedSignersFile=~/.ssh/allowed_signers, plus the line "<email> <public-key>" appended to that file (show me the file first and never overwrite existing entries). Never print private key material.
3. Look for repo-local overrides that would switch signing off (`git config --local commit.gpgsign` in the repos I name) and report them. Do not change them without asking.
4. Container: `container run --ssh` forwards the host's SSH_AUTH_SOCK, and in many shells that is the macOS launchd agent, not 1Password (check `echo $SSH_AUTH_SOCK`). Propose a small shell function or alias that sets SSH_AUTH_SOCK to the 1Password socket only for the `container run --ssh` call, and add it to my shell profile only after I confirm. Inside the container the macOS op-ssh-sign binary does not exist: use gpg.format=ssh, the same user.signingkey and commit.gpgsign=true there, and leave gpg.ssh.program unset so git falls back to ssh-keygen.
5. Verify, using throwaway repos in a temp directory and never my real ones. On the host: make an empty commit and run `git log --format=%G? -1`, expecting G. In a container: `SSH_AUTH_SOCK=<1Password socket> container run --rm --ssh <image with git and ssh-keygen, for example node:24-bookworm>`, with git configured inside the throwaway repo as in step 4, same steps, expecting G. Report both results. Do not push anything.

Requirements: macOS, 1Password with the SSH agent turned on, Apple container with --ssh.

Honest limits

This was tested on macOS with Apple container 1.6.1, in a throwaway repo and not a bind-mounted project. --ssh and the SSH_AUTH_SOCK override are needed on every run, or export the variable in your shell. Set it for your next command:

bash
SSH_AUTH_SOCK="$HOME/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" container run --rm --ssh node:24-bookworm ssh-add -L