"The push succeeded. The CLI failed. Same machine, same user, same second — the only thing different was the door."
The setup
A headless SSH session on the control-plane Mac was bootstrapping a repository. Git over SSH worked perfectly: it authenticated to the remote and pushed without complaint. By every obvious measure, this session had working access to GitHub.
The wall
Then gh, the GitHub CLI, failed on the same box, in the same session, for the same user. Why? Because gh keeps its auth token in the login Keychain, and a headless SSH session has no SecuritySessionID — no login session to unlock that Keychain with. Git's SSH key lived somewhere the SSH envelope could reach; gh's token lived somewhere it couldn't. One machine, one user, two credentials in two different rooms — and this door only opened one of them.
The wrong fix
The reflex was gh auth login — re-authenticate, surely that fixes an auth failure. It doesn't. Re-authenticating inside an envelope that structurally cannot hold the credential just produces a fresh failure. You can run gh auth login a hundred times; the headless door still has no session to unlock the Keychain the new token would land in. The loop feels like progress and is pure motion.
The right fix
Use the capability you actually have. The SSH transport had already authenticated and pushed — so lean on that. Or, if the task genuinely needs the Keychain token, run it through an interactive executor that has a login session. The operation never needed a new credential; it needed the right envelope for the credential it already had. Host identity did not imply credential availability — and that gap is the whole lesson.