[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
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
paperbenni(GitHub profile, opens in a new tab) added labelsbug
paperbenni(GitHub profile, opens in a new tab) added labelsneeds-triage
paperbenni(GitHub profile, opens in a new tab) changed the title
juliusmarminge added labelsneeds more info
juliusmarminge added labelsvia-triage
juliusmarminge removed labelsneeds-triage
juliusmarminge removed labelsbug
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.
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 environmenton every retry.Diagnosis#
An older server, 0.0.45, was still running from the remote
~/.t3. The launcher adopted it asexternaland minted the pairing grant with its own 0.1.0 runner. The 0.1.0 CLI writes grants tostatev2.sqlite, but the 0.0.45 server readsstate.sqlite, so/oauth/tokenrejected the grant.On this host nobody started the old server by hand. The desktop had launched it as
managedunder the state key of the connection's previous alias. After the alias changed, the new key adopted the server asexternal, so no update would ever replace it.Steps to reproduce#
Derived from the logs and the launch script, not replayed end to end:
- Connect an SSH environment with an older desktop and let it launch the remote server.
- Change the connection's alias, user, or port, then reconnect. The launch now reports
remoteServerKind: "external". - 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 serveran fromruntime/versions/0.0.45and held onlystate.sqliteopen, while the launcher'srun-t3.shpinnedT3_ARCHIVE_VERSION='0.1.0'. The first pairing attempt with the 0.1.0 CLI createdstatev2.sqlite. The 0.0.45 server kept writingstate.sqlitefor about five more hours.Related issues#
- #17550 pairs reused servers with their own CLI version. That fixes the pairing side and covers this report.
- #21892 keeps a server the launcher started
managedafter a connection edit, so updates still replace it.
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 currentstate.sqlite, and the desktop connected.If you recovered by stopping the old server, check your data. The new server imports V1 only when
statev2.sqliteis missing, so anything written after the first failed pairing is not in V2.state.sqliteis left untouched, so stopping the server, movingstatev2.sqlite*aside, and starting it again imports it once more.Filed by#
Claude Opus 5.5 in Claude Code, run from T3 Code.
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.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
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
t3runner against that default home (tunnel.ts:750-760). A server you started yourself withnpx t3can end up being the one that receives it.Please reply with:
t3server you started yourself was running on the host when you connected, and whether connecting works with it stopped.npx t3version on the host.server.logunder~/.t3/ssh-launchon the host.