Skip to content

remote: Reuse existing SSH ControlMaster sessions#51604

Merged
Veykril merged 3 commits intozed-industries:mainfrom
nicosalm:reuse-ssh-controlmaster
Apr 21, 2026
Merged

remote: Reuse existing SSH ControlMaster sessions#51604
Veykril merged 3 commits intozed-industries:mainfrom
nicosalm:reuse-ssh-controlmaster

Conversation

@nicosalm
Copy link
Copy Markdown
Contributor

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:

@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 15, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @nicosalm on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 15, 2026
@nicosalm
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Mar 15, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot Bot commented Mar 15, 2026

The cla-bot has been summoned, and re-checked this pull request!

@maxdeviant maxdeviant changed the title remote: reuse existing SSH ControlMaster sessions remote: Reuse existing SSH ControlMaster sessions Mar 15, 2026
@nicosalm nicosalm marked this pull request as ready for review March 27, 2026 01:06
@zed-codeowner-coordinator zed-codeowner-coordinator Bot requested review from a team, Veykril and reflectronic and removed request for a team March 27, 2026 01:06
Copy link
Copy Markdown
Member

@Veykril Veykril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, and sorry for the late review!

@Veykril Veykril enabled auto-merge (squash) April 21, 2026 07:16
@Veykril Veykril merged commit a8cdff3 into zed-industries:main Apr 21, 2026
31 checks passed
@yeskunall
Copy link
Copy Markdown
Member

Hey @nicosalm -- improvements like this make the DX better for everyone. Thanks for working on this and congratulations on your first contribution to Zed! 💖

@nicosalm nicosalm deleted the reuse-ssh-controlmaster branch April 21, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Existing SSH Sessions Not Reused with ControlMaster

3 participants