Skip to content

[Bug]: New worktree threads fail when the Git remote uses an SSH key with a passphrase #38622

Closed as not planned

Description

@PaulAshraf

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. Use an SSH key that has a passphrase and is not loaded in an SSH agent (for example, ssh-add -D).
  2. Add a project whose origin is an SSH remote, such as git@github.com:<user>/<repo>.git.
  3. Start a new thread with New worktree, using the default remote base (start from origin), and send a prompt.

Expected behavior

T3 Code asks for the key passphrase, the way a terminal does, and creates the worktree.

Actual behavior

The worktree base fetch runs with every prompt turned off (GIT_ASKPASS=, GIT_TERMINAL_PROMPT=0, SSH_ASKPASS=, SSH_ASKPASS_REQUIRE=never), so ssh has no way to ask for the passphrase:

  • Desktop app (no TTY): the fetch fails right away and the thread fails with Workspace preparation failed during provision worktree: … Git could not authenticate with the remote. Check Git credentials or SSH access on the server, then retry. Retrying fails the same way.
  • t3 started from a terminal: ssh asks for the passphrase on the server's own terminal instead. The thread sits on "Fetch base branch" until the 5-minute fetch timeout.

A thread without a worktree works, because it doesn't fetch.

I reproduced both cases against a local sshd with a passphrase-protected ed25519 key, running git with the same environment the driver uses:

# no TTY (desktop)
$ GIT_ASKPASS= GIT_TERMINAL_PROMPT=0 SSH_ASKPASS= SSH_ASKPASS_REQUIRE=never git ls-remote fixture:repo.git
user@127.0.0.1: Permission denied (publickey).
fatal: Could not read from remote repository.

# with a TTY (terminal-launched server)
Enter passphrase for key '~/.ssh/id_ed25519':      <- waits on the server's terminal

Impact

Blocks work completely: anyone with a passphrase key who doesn't keep it in an agent can't start a worktree thread from origin.

Version or commit

Desktop 0.1.10 (Beta). The code path is unchanged on main at 6a29d58.

Environment

macOS 27.2.1 arm64, OpenSSH 10.5p1, desktop app as the server.

Screenshots, recordings, or supporting files

New worktree thread on main (6a29d58) against a local sshd with a passphrase-protected key. Setup fails at "Fetch base branch" in under 100 ms. The machine name and home paths were replaced with generic text before capture.

Worktree setup fails at Fetch base branch with "Git could not authenticate with the remote"

Workaround

Load the key into an agent before starting the thread (ssh-add --apple-use-keychain ~/.ssh/id_ed25519), or turn off "start from origin" for the worktree.

Related

Proposed fix

I have a working fix and can open a PR if that's wanted. It is scoped to the new-worktree base fetch only:

  • The fetch runs with the existing askpass helper from packages/ssh (already used for desktop SSH connections). In probe mode the helper declines ssh's prompt and reports the exact prompt text.
  • The worktree setup card (web and mobile) shows that prompt with a password field. The answer goes over a new worktreeSetup.answerCredential RPC, redacted on the server, and is never saved.
  • The fetch reruns with the answer, which the helper gives only to that exact prompt. A wrong passphrase asks again. Cancel works, the prompt times out after 10 minutes, and Windows keeps today's behavior.
  • People without a passphrase key see no change.

I checked it end to end against real OpenSSH: no answer gives today's error; a wrong passphrase re-asks; the correct one fetches origin/main.

Activity

  1. juliusmarminge commented on Nov 18, 2026

    @juliusmarminge
    Member

    Thanks for writing this up. It asks for new behaviour rather than reporting a defect, so it does not belong in the bug tracker and I'm closing it as not planned here. Feature ideas are discussed in Discussions: please post it there.

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