Skip to content

[Bug]: Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session. #21681

Closed

Description

@paperbenni

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

Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.

Add a normal Arch linux machine over ssh

  • node and bun are installed over mise
  • ssh works fine, herdr, zed, vs code remotes work fine
  • npx t3 on the machine itself works fine

Expected behavior

it installs current t3 code and connects to the server

Actual behavior

Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.

this error message

Impact

Blocks work completely

Version or commit

0.1.0

Environment

Arch linux, Ryzen CPU, Wayland compositor, sshd enabled

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

No response

Activity

  1. added
    bug
    needs-triage
    on Oct 19, 2026
  2. changed the title [-][Bug]:[/-] [+][Bug]: `Could not prepare the SSH environment: Error invoking remote method 'desktop:bootstrap-ssh-bearer-session': DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.`[/+] on Oct 19, 2026
  3. juliusmarminge commented on Oct 19, 2026

    @juliusmarminge
    Member

    Note

    Grok responding on behalf of Julius.

    We need more detail to tell why the remote server rejected the pairing credential. A 401 at this step means the remote T3 server answered and refused the credential the desktop created over SSH (sshEnvironment.ts:63-65). So the remote launch and node lookup, including mise, had already worked. The launcher also adds mise shims to PATH (tunnel.ts:387-391).

    The launcher reuses a T3 server that is already running from the default home instead of starting its own (tunnel.ts:652-690). It then creates the pairing credential with the launcher's own t3 runner against that default home (tunnel.ts:750-760). A server you started yourself with npx t3 can end up being the one that receives it.

    Please reply with:

    1. Whether a t3 server you started yourself was running on the host when you connected, and whether connecting works with it stopped.
    2. The npx t3 version on the host.
    3. The contents of server.log under ~/.t3/ssh-launch on the host.
  4. added
    needs more info
    via-triage
    and removed
    needs-triage
    bug
    on Oct 19, 2026
  5. paperbenni commented on Oct 19, 2026

    @paperbenni
    Author

    An older t3 server was already running, manually sshing into the server killing t3 there and doing npx t3 service install fixed the issue. It would be nice if t3 code would show a nicer error message though or would even do this for me.

  6. Gooder24 commented on Oct 19, 2026

    @Gooder24
    Contributor

    Same 401 on another host. Here's the diagnosis you asked for above.

    What happened

    The desktop updated to 0.1.0. After that, an SSH environment showed Reconnecting: Could not prepare the SSH environment on every retry.

    Diagnosis

    An older server, 0.0.45, was still running from the remote ~/.t3. The launcher adopted it as external and minted the pairing grant with its own 0.1.0 runner. The 0.1.0 CLI writes grants to statev2.sqlite, but the 0.0.45 server reads state.sqlite, so /oauth/token rejected the grant.

    On this host nobody started the old server by hand. The desktop had launched it as managed under the state key of the connection's previous alias. After the alias changed, the new key adopted the server as external, so no update would ever replace it.

    Steps to reproduce

    Derived from the logs and the launch script, not replayed end to end:

    1. Connect an SSH environment with an older desktop and let it launch the remote server.
    2. Change the connection's alias, user, or port, then reconnect. The launch now reports remoteServerKind: "external".
    3. Update the desktop to a release whose CLI writes a different database, such as 0.0.45 → 0.1.0, and reconnect.

    Version

    Desktop 0.1.0. Remote server 0.0.45, with the 0.1.0 runtime installed next to it by the launcher.

    Environment

    The desktop runs on Arch Linux under Wayland. The remote is Ubuntu 24.04 x64 with the release-archive runtime and no Node.

    Evidence

    Desktop trace:

    ssh.environment.ensure.succeeded { remotePort: 3773, remoteServerKind: "external", issuedPairingToken: true }
    DesktopSshEnvironmentRequestError: [ssh_http:401] SSH remote API request failed during bootstrap-bearer-session.
      [cause]: EnvironmentAuthInvalidError: The environment rejected this client's credentials (invalid_credential).
    

    Remote server trace:

    environment.auth.token POST /oauth/token -> EnvironmentAuthInvalidError (invalid_credential)
      at environment.auth.token (file:///<home>/.t3/runtime/versions/0.0.45/t3)
    

    On the remote, t3 serve ran from runtime/versions/0.0.45 and held only state.sqlite open, while the launcher's run-t3.sh pinned T3_ARCHIVE_VERSION='0.1.0'. The first pairing attempt with the 0.1.0 CLI created statev2.sqlite. The 0.0.45 server kept writing state.sqlite for about five more hours.

    Related issues

    Fix applied or workaround

    I stopped the 0.0.45 server, moved the stale statev2.sqlite* aside, and let the desktop relaunch. The 0.1.0 server imported the current state.sqlite, and the desktop connected.

    If you recovered by stopping the old server, check your data. The new server imports V1 only when statev2.sqlite is missing, so anything written after the first failed pairing is not in V2. state.sqlite is left untouched, so stopping the server, moving statev2.sqlite* aside, and starting it again imports it once more.

    Filed by

    Claude Opus 5.5 in Claude Code, run from T3 Code.

  7. t3dotgg commented on Oct 21, 2026

    @t3dotgg
    Member

    Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    Thanks for the report. One part of this is fixed in current main. Merged #17550 mints pairing credentials with the runtime of a reused managed server, fixing the reported old-server credential mismatch. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: a managed server can still be adopted as external after the SSH alias changes. If that part still matters to you, please open a new issue for that part only.

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

    needs more infovia-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions