Skip to content

[Bug]: SSH-launched server on macOS can't read the login keychain, so gh fails in remote threads #17936

Open

Description

@oryan-block

Setup

  • Host: macOS 26.7, T3 Code desktop 0.0.45
  • Second PC connects to the Mac through the built-in SSH environment
  • gh 2.97.0 logged in with the default storage (login keychain). git uses gh auth git-credential for github.com.

What happens

Agents in threads served by the SSH-launched server can't use GitHub, so https pushes fail too, and the server's own PR integration logs:

GitHubCliAuthenticationError: GitHub CLI failed in execute: GitHub CLI is not authenticated. Run `gh auth login` and retry.

At the same time, on the same Mac, agents spawned by the desktop app's server have a working gh. It also looks like gh "stops working mid-session", since a thread started locally and continued from the other PC resumes on the SSH server.

Same thing outside T3, from the other PC:

$ ssh mac /opt/homebrew/bin/gh auth status
github.com
  X Failed to log in to github.com account <user> (default)
  - Active account: true
  - The token in default is invalid.

Locally on the Mac, gh auth status shows the account logged in through (keyring).

Why

When no server is registered in ~/.t3/userdata/server-runtime.json (e.g. the desktop app isn't running), the SSH launcher starts its own with nohup ... run-t3.sh serve ... inside the SSH session. That server and every agent it spawns end up in the SSH login's security session instead of the user's GUI session, so they can't read the login keychain and gh finds no token. Its env has no SECURITYSESSIONID, XPC_SERVICE_NAME or __CFBundleIdentifier, unlike the desktop app's children.

When the desktop app is running, the launcher adopts its server and everything works, which is why it looks intermittent.

Workaround

Suggestion

On macOS, when the user has a GUI session, start the managed server inside it (e.g. through the user's gui/<uid> launchd domain) instead of as a child of sshd. Not sure that's doable from an SSH session without root though 🤔. At minimum, detect it and show something clearer than "not authenticated", like "this server runs outside your login session, so keychain-backed credentials (gh, git-credential-osxkeychain) won't work".

Activity

  1. juliusmarminge commented on Oct 22, 2026

    @juliusmarminge
    Member

    Triaged as an ordinary bug: the report describes failed credential access, not an exploitable vulnerability. The triage host is Linux, so it cannot exercise the reported macOS GUI-session/keychain setup. No runtime reproduction or fix is claimed. A maintainer with a macOS host and keychain-backed GitHub CLI login needs to compare SSH-launched and desktop-launched servers; changing the security session used to access credentials requires maintainer review. Leaving this issue open.

  2. serabi commented on Oct 22, 2026

    @serabi

    Same problem here, but with Claude Code instead of gh. It's a follow-on to the update race I reported in #5749 (comment): this time, the server that won the race couldn't read the keychain, so Claude stopped authenticating.

    Setup: my Mac connects over the built-in SSH environment to another Mac (arm64) that runs the T3 Code desktop app. Both are on 0.1.2-nightly.20261022.3526. Claude Code 2.1.308 on the host is logged in with a Claude Max subscription, stored in the login keychain.

    After the nightly update, Claude threads on the host failed with "Claude Code is not authenticated. Run claude auth login and try again." The account was still logged in.

    On the same host and build:

    • Server started by the SSH launcher (managed): Claude shows as unauthenticated. One relaunch timed out on the Claude check instead.
    • The desktop app's own server, adopted by the launcher (external): Claude shows as authenticated.

    From a new SSH session on the host:

    $ security show-keychain-info ~/Library/Keychains/login.keychain-db
    security: SecKeychainCopySettings ~/Library/Keychains/login.keychain-db: User interaction is not allowed.
    $ claude auth status
    "loggedIn": false
    

    Running security unlock-keychain over ssh -t only helped in that one session. The next SSH session still saw the keychain as locked. ~/.claude/.credentials.json on the host has empty tokens, so Claude can't fall back to it.

    How the update set this off: the host's desktop app restarted for the update and its server exited with ServerAlreadyRunningError, because the server my client had started over SSH still owned ~/.t3/userdata. My client then restarted that SSH server on the new version, and the new one couldn't read the keychain. I stopped it once, and the client started it again about 30 seconds later, before the desktop app could take over. This is the same race.

    One thing I can't explain: an older SSH-started server on this host ran Claude fine until a minute before this happened.

    What fixed it: I quit the client and stopped the SSH server. I opened the desktop app on the host first, then reconnected. The launcher used the desktop app's server, and Claude works again.

    Agree with the suggestion above. The "run claude auth login" message is misleading here. It would help if T3 said the server can't read the keychain because it was started over SSH, and suggested keeping the desktop app open on the host.

    Triaged with Claude Code (claude-opus-5-5) via t3 triage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions