Add setting to enable reusing user's existing control master#12465
Merged
Conversation
alokedesai
approved these changes
Jun 10, 2026
|
|
||
| // Reuse-ControlMaster only applies to the legacy (ControlMaster) | ||
| // SSH wrapper, which is bypassed while the tmux wrapper is in use. | ||
| if !should_prompt_ssh_tmux_wrapper { |
Member
There was a problem hiding this comment.
Is this setting meant to be permanent or just a temporary state before we enable it for everyone? If the latter, i'd advocate for a simpler approach where we only make the setting available in the file and don't expose anything in the UI
Member
Author
There was a problem hiding this comment.
I think we should have a permanent setting in case user actually want Warp to always create a master connection. There are actual use cases for this imo (e.g. user has limited number of control paths per master connection)
5449277 to
730a239
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Problem
Some users manage their own SSH
ControlMasterfor a host: their ssh config setsControlMaster auto+ControlPath, and that master owns shared state — in the reported case, a reverse-forwarded (RemoteForward) socket used by all of their SSH clients. Warp's SSH wrapper always forces-o ControlMaster=yes -o ControlPath=~/.ssh/<session_id>on warpified sessions, so connecting from Warp creates a second, competing master for the same host. Only one connection can bind the reverse forward, so the two masters race over it and the user's tooling becomes unreliable (Warning: remote port forwarding failed ...).Fix
Behind a new opt-in setting (
warpify.ssh.reuse_existing_control_master, default off; toggleable from the Warpify settings page and the Command Palette), the SSH wrapper now looks for a live master the user already runs for the destination before creating its own:ssh -G "$@"resolves the user's effectiveControlPath, with tokens (%h/%p/%r/%C) expanded into a literal path.ssh -O checkverifies a master is actually alive on that socket. Both probes are local-only commands.ControlMaster=noagainst the user's socket — Warp becomes just another client of the user's master, so there is no second master and no forward conflict. All multiplexed traffic (remote-server proxy, scp, generators) flows through the same socket unchanged.ControlPathconfigured, dead master, path characters we can't safely embed, older ssh), the wrapper falls back to today's behavior exactly.Master ownership is threaded end-to-end so teardown is safe: the SSH DCS hook reports a new
external_masterfield, plumbed throughIsLegacySSHSession→SshTransport→ a newControlPathenum (WarpManaged/UserOwned/None) on the remote-server session state. Session teardown only runsssh -O exitagainstWarpManagedmasters — Warp never tears down a master the user owns.Alternatives considered
ClearAllForwardings=yesin the wrapper): prevents this specific conflict but still leaves two masters per host, doesn't address non-forward conflicts, and silently drops forwards users do want in Warp sessions.%C,%r@%h:%p), which are the recommended and most common setup.placeholder@placeholder. Most general, but a much larger change — and unnecessary, sincessh -Galready yields a literal expanded socket path that the existing socket-only transport consumes as-is.RemoteForwardto a dedicated master started outside Warp. Works, but pushes config surgery onto every affected user and leaves the surprising two-master behavior in place.Rollout
Default off for safety: reusing a master couples Warp's session lifetime to the user's master and shares its
MaxSessionschannel budget, which existing multiplexing users may not expect. Once validated more broadly we can flip the default and keep the setting as an escape hatch.Linked Issue
No linked issue — this addresses a customer support request about the SSH wrapper's forced ControlMaster conflicting with user-managed masters.
ready-to-specorready-to-implement.Testing
./script/runAutomated
external_masterfield, including the default (false) for hooks emitted by older bootstrap scripts.SshTransportownership parameter;cargo nextestpasses for the affected crates;./script/format+ clippy clean.bash -n,zsh -n,fish --no-execute).Manual E2E (
./script/runagainst a remote devbox configured like the customer:ControlMaster auto, tokenizedControlPath,RemoteForward):~/.ssh, no port-forward failure, session fully warpified, remote-server features work over the reused socket.ssh -O checkconfirms the user's master is still running (Warp did not tear it down) and the reverse forward stays bound.ControlPathconfigured behaves identically to today.Agent Mode
Conversation | Options plan
CHANGELOG-IMPROVEMENT: Added an opt-in setting (
warpify.ssh.reuse_existing_control_master) that makes Warp's SSH wrapper attach to an existing SSH ControlMaster for the destination host instead of always creating its own, preserving user-managed masters and their port forwards.Co-Authored-By: Oz oz-agent@warp.dev