zed/crates/remote
Nico a8cdff3739
remote: Reuse existing SSH ControlMaster sessions (#51604)
Closes #45271

Zed hardcodes `ControlMaster=yes` with a `ControlPath` in a random temp
directory, so it can never find a ControlMaster session the user already
has open. This means you get prompted for credentials again even if
you're already authenticated.

This patch checks for an existing master before spawning a new one. It
runs `ssh -G` to resolve the user's configured `controlpath` (with `%h`,
`%p`, etc. already expanded), then `ssh -O check` to verify it's alive.
If it is, Zed skips askpass and uses the existing socket. If not, the
current behavior is unchanged. Both commands are local and don't hit the
network.

Also adds a `killed: AtomicBool` to `SshRemoteConnection` because
`has_been_killed()` was using `master_process.is_none()` as a proxy for
"connection is dead." When reusing an external master, `master_process`
starts as `None`, so the connection pool would discard it immediately.

Tested against a university SSH setup with `ControlMaster auto`
configured. The reuse path connects without prompting, and the fallback
path works normally when no master exists. Windows is unaffected.

Release Notes:

- Zed now reuses existing SSH ControlMaster sessions instead of
prompting for credentials again (#45271).
2026-04-21 07:44:24 +00:00
..
src remote: Reuse existing SSH ControlMaster sessions (#51604) 2026-04-21 07:44:24 +00:00
Cargo.toml Fix a few cases where we weren't escaping shell vars correctly (#50562) 2026-03-02 23:31:11 -07:00
LICENSE-GPL Add the ability to edit remote directories over SSH (#14530) 2024-07-19 10:27:26 -07:00