I sign all my commits with an SSH key that lives in 1Password, which works well when I'm at the keyboard, because the vault is unlocked and a signature is one Touch ID tap away. It works a lot less well when a coding agent is supposed to run overnight in one of my side projects, since the vault locks itself after a while and from then on every git commit hangs, waiting for an approval nobody is there to give. These are notes on moving signing for that repo onto a Secure Enclave key, and on two small details in git and ssh-keygen that took most of the time.
Why not just a key on disk
The obvious answer is to generate a passphrase-less ed25519 key, put it in ~/.ssh, and point git at it for personal repos only. It works, but it leaves a plaintext private key on disk that anything running as your user can copy, which is a strange trade to make for a setup whose whole point is to let a process run unsupervised (I also dismissed the Keychain plus system agent route at first, because macOS doesn't reliably reload keys into the agent at login, which turned out not to matter, since an overnight run always starts from a live, logged-in session anyway).
Secretive is a better fit. It's a small macOS app that creates keys inside the Secure Enclave and serves them through its own SSH agent, so the private key can't be exported at all, and if you create the key without requiring authentication it signs silently, with no prompt. The key type is ECDSA P-256, because that's what the Enclave supports, and GitHub accepts it as a signing key.
Pointing only signing at Secretive
Secretive's setup screen suggests changing IdentityAgent in ~/.ssh/config to its socket. I skipped that, because I still want 1Password to handle interactive SSH (pushing, connecting to servers), and only signing should go to the Enclave. That split is easy to get, since the 1Password socket is set by IdentityAgent in ~/.ssh/config and ssh-keygen -Y sign doesn't read ~/.ssh/config at all, it talks to whatever SSH_AUTH_SOCK says.
So we can give git a tiny wrapper as gpg.ssh.program, which repoints the variable and then calls the real ssh-keygen:
#!/bin/sh set -eu SSH_AUTH_SOCK="$HOME/Library/Containers/com.maxgoedjen.Secretive.SecretAgent/Data/socket.ssh" export SSH_AUTH_SOCK if [ ! -S "$SSH_AUTH_SOCK" ]; then echo "Secretive's agent socket is missing at $SSH_AUTH_SOCK" >&2 exit 1 fi exec /usr/bin/ssh-keygen "$@" And then we configure it in the repo itself rather than globally, so the other repos keep signing through 1Password (worktrees read the main repo's .git/config too, so they pick it up without any extra setup):
git config --local gpg.format ssh git config --local commit.gpgsign true git config --local gpg.ssh.program /Users/me/.local/bin/git-ssh-sign-secretive git config --local user.signingkey "key::$(cat /Users/me/.ssh/id_secretive.pub)" Use absolute paths. Git doesn't expand
~inuser.signingkeyfor the ssh format, and if you haveextensions.worktreeConfigturned on, it's worth checking that no per-worktree config overrides these.
The key:: part
My first attempt set user.signingkey to the path of the public key file, the way most guides show it, and signing failed with No private key found for public key "…/id_secretive.pub". I assumed for a bit that the wrapper wasn't reaching the agent, but the socket was fine. When ssh-keygen -Y sign gets a public key with -f, it looks for the private half next to it on disk, and it only asks the agent for it when it also gets -U. There is no private key file next to a Secretive key, so without -U it has nowhere to look.
Git does pass -U, but only when it thinks user.signingkey holds the key itself rather than a path to it, and it decides that by looking for the key:: prefix or for a value that starts with ssh-. An ed25519 key starts with ssh-ed25519, so it gets recognised either way, but an Enclave key starts with ecdsa-sha2-nistp256, so without the prefix git takes it for a file path. That's why the config above writes the key inline, behind key::.
With an agent-held key that isn't ssh-*, always use the key:: form.
To check that 1Password is really out of the loop, we can commit with the ambient socket pointed at nothing, so only the wrapper's socket could possibly work:
SSH_AUTH_SOCK=/nonexistent git commit --allow-empty -m "signing test" git log --show-signature -1 Checks that ask the wrong agent
The repo also had a pre-commit check that makes sure signing will work before a long run starts, so a locked vault fails loudly in the first minute and not at the first commit three hours in, and that check blocked the very first commit. It listed the keys of the current agent with ssh-add -L and looked for the signing key there, which used to be a reasonable test, but ssh-add -L asks the agent in the ambient SSH_AUTH_SOCK, and the Enclave key only exists behind the socket the wrapper sets. So the check could never see it, and reported signing as broken while signing worked fine.
The fix was to stop treating that listing as evidence. The only conclusive test is to sign something the same way git would, with the configured gpg.ssh.program, the key written to a temporary file, and -U when the key is a literal:
"$signer" -Y sign -n git -f "$key_file" -U "$payload" If that produces a signature, signing works, whatever ssh-add -L says. The listing is still useful, but only after a real signature has failed, to tell "the agent has the key but won't sign" (a locked vault) apart from "the agent doesn't have the key at all". The same check also had the ssh-* assumption from the previous section baked in and took the ecdsa-sha2-nistp256 key for a file path, so it now matches ecdsa-sha2-* and the sk- FIDO types as well, and trusts key:: whenever it's there.
The commit with that fix was the first one signed through the Enclave, and GitHub showed it as verified. I haven't tried signing while the screen is locked yet, which is the case all of this is for, so that's worth testing before trusting it with a real overnight run.
So, to let an agent sign commits unattended, we can keep the key in the Secure Enclave with Secretive, point only git's gpg.ssh.program at its socket so interactive SSH stays with 1Password, and write the key inline behind key::, because git only asks the agent for an ecdsa-sha2-nistp256 key in that form. And when a check needs to know whether signing works, it should sign something the way git does, since ssh-add -L only tells you what the ambient agent holds.