[BUG] SSH sessions can't authenticate on macOS
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
I can't use Claude Code over SSH on macOS. OAuth works perfectly when I'm using the machine locally, but fails completely over SSH. The claude setup-token workaround switches to API key pricing, which defeats the point of having a subscription.
This appears to affect a lot of people based on #5515 (55+ upvotes), #9403, and #5957.
What I tried
I spent hours testing workarounds from the related issues:
security unlock-keychain(from #5515, #1222, #9403) - keychain unlocks successfully but Claude still can't read credentialssecurity set-generic-password-partition-list- modified ACL permissions but no effect in SSH context- Creating duplicate keychain entries to fix service name mismatch (from #9403) - copied "Claude Code-credentials" to "Claude Code" but still fails
- Setting "Always Allow" locally before SSH-ing - permissions don't carry over to SSH sessions
AFAICT... none of these work because SSH sessions fundamentally lack the GUI security context needed to access macOS Keychain. I think this is an architectural limitation of macOS, not something that is simple to work around.
I'm not expert in this area, but it seems like other popular CLI tools such as gh, gcloud, etc all support SSH by using file-based credential storage instead of relying solely on Keychain:
- gh - stores tokens in
~/.config/gh/(docs) - gcloud - uses
~/.config/gcloud/with device code flow for SSH (docs)
Suggestion
Could Claude Code detect SSH sessions and fall back to encrypted file storage?
This would let us use our OAuth subscriptions over SSH while keeping Keychain security for local usage. The file would be encrypted and chmod 600, similar to how other CLI tools handle it.
Happy to provide more details or test any experimental builds.
What Should Happen?
I should be able to use my subscription while ssh'd to a mac.
Error Messages/Logs
Steps to Reproduce
ssh to a Mac
Claude Model
None
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.25
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗