remote-tmux: recover interactive SSH auth when a ProxyCommand transport closes silently
Summary
When cmux mirrors a remote host's tmux over ssh tmux -CC, the first step is a BatchMode=yes discovery probe over the shared SSH ControlMaster. If the host is reached through an ssh ProxyCommand / ProxyJump whose own pre-handshake step (authentication, host-key, or a 2FA/MFA leg) needs a terminal, that step can't prompt under BatchMode, so the proxy closes the pipe before OpenSSH emits any auth-failure string. cmux saw only OpenSSH's pipe-transport placeholder (Connection closed by/to UNKNOWN port 65535) and treated it as a hard failure — so it never offered the interactive retry it already uses for Permission denied / host-key TOFU / MFA, and the connection failed outright.
Fix
Classify a silent ProxyCommand transport closure as interactive-retry-recoverable, so the existing "run ssh in your terminal, then retry over the now-authenticated master" path kicks in.
- Adds
indicatesProxyCommandTransportClosedand a composedindicatesInteractiveRetryWillHelp, routed through all three discovery/attach sites so no entrypoint silently regresses. - Only silent closures are treated as recoverable — an interactive retry can't fix a host that's refusing, unreachable, or unresolvable. The placeholder is ignored when stderr also carries an explanatory marker:
connect failed:,: open failed:,stdio forwarding failed,kex_exchange_identification:,Connection refused,No route to host,could not resolve hostname(OpenSSH's DNS wrapper), andnodename nor servname provided(BSD/macOSgetaddrinfoNXDOMAIN, e.g. anc-basedProxyCommand).
Tests
cmuxTests/RemoteTmuxAuthTests — positive cases for the silent closures we must recover, and negative cases for every explained closure we must skip. 42 tests pass.
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.
Summary by cubic
Restores interactive SSH auth when a ProxyCommand/ProxyJump closes the transport silently during BatchMode discovery. Adds a composed retry check and skips explained proxy failures (including DNS, timeouts, banner/pre-auth, port-forward errors, and local ProxyCommand launch errors) to avoid futile prompts.
- Bug Fixes
- Added
indicatesProxyCommandTransportClosedand composedindicatesInteractiveRetryWillHelp; all discovery/attach paths use the composed predicate. - Treat only silent proxy closures as recoverable; exclude stderr with diagnostic markers (connect/open/stdio/port-forward; refused/no route/unreachable; DNS resolution via OpenSSH wrapper and BSD/Linux/macOS
getaddrinfo; TCP timeouts on macOS/Linux;ssh_exchange_identification:/kex_exchange_identification:; shell launch errors like “command not found”, “: not found”, “no such file or directory”, “exec format error”). - Added focused tests (
RemoteTmuxProxyTransportRetryTests) covering silent vs explained proxy closures, includingncDNS NXDOMAIN (Linux/BSD), Linux connect timeouts, banner-exchange closures, and shell launch failures.
- Added
Summary by CodeRabbit
-
New Features
- Improved remote Tmux retry handling so the app can better recognize when an interactive SSH retry is likely to help.
- Expanded failure detection to include additional recoverable connection-closure cases.
-
Bug Fixes
- Made attach and window-mirroring flows more likely to retry correctly after recoverable SSH errors.
- Reduced false positives by excluding clearly non-recoverable connection failures from retry suggestions.
-
Tests
- Added coverage for proxy-closure, auth-required, and non-recoverable SSH failure scenarios.