Windows: two ssh --proxy-mode bugs the open PRs do not cover #97
Le-Anh-Duy
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Posting here rather than as PRs, per CONTRIBUTING.
While getting the CLI working on Windows 11 (Python 3.13,
google-colab-cli==0.6.0) I ran into four separate failures. Two are already covered by open PRs; two are incommands/ssh.pyand I could not find them addressed anywhere — none of the open Windows PRs (#70, #75, #84, #86) touch that file's--proxy-modepath.Everything below was verified end to end against a live T4 runtime: interactive shell, remote command, and
scpin both directions.1.
select.select()on a pipe killsssh --proxy-mode, silently_bridge_proxy_mode's stdin pump:On Windows
select()accepts sockets only, so this raisesOSError: [WinError 10038]. The surroundingexcept (OSError, websocket.WebSocketException): passswallows it, the thread dies, and the client → server direction is dead while server → client keeps working.The symptom is confusing: the SSH banner arrives, then the connection drops before key exchange.
Worth noting the call buys nothing on any platform: with a
Nonetimeout it only repeats what the blockingos.readunderneath already does. Deleting it is a simplification that happens to fix Windows.2.
shlex.joinquoting reachesCreateProcessW_proxy_commandbuilds the string withshlex.join, whose POSIX quoting wraps the backslashes insys.executable:Windows OpenSSH spawns a ProxyCommand through
CreateProcessWwith no shell in between, so it looks for a file whose name literally contains those quotes:subprocess.list2cmdlineproduces the quoting that parser expects.One caveat for whoever fixes this:
tests/test_ssh.py::test_proxy_command_round_trips_through_the_shellasserts the round trip withshlex.split, which is the POSIX parser. Loosening that assertion would drop a real security contract — a session name like$(touch /tmp/pwned)must arrive as one literal argument. Splitting withCommandLineToArgvWon Windows keeps the contract enforced on both platforms; reverting the fix then turns 14 of those cases red.3 & 4. Already covered by open PRs
import termios/import ttyinconsole.pyaborts every command on Windows (Windows: google-colab-cli v0.6.0 crashes on startup due to unconditional termios import #78; feat: Add native Windows support and lazy console imports #84, Add Windows support #75, feat: add Windows native support via platform terminal abstraction #70).signal.SIGHUPin_install_rm_signal_handlers(Add native Windows support #86 already usesgetattr).Mentioned only so the picture is complete.
Two things I found useful enough to build
Attaching to a runtime that already exists — which I have since found is already #49, where it is better placed; I have added the mechanism detail there and closed my duplicate issue.
Generating the
~/.ssh/configentries.--proxy-modeis only usable once a host block points at it, and writing that by hand is easy to get wrong: a shell wrapper inProxyCommanddies on Windows for the reason in §2, and aimingUserKnownHostsFileat the real file fills it with warnings because every new runtime brings a new host key. Aconfig-sshcommand that rewrites only a marked region — the shapegcloud compute config-sshuses — makes plainssh,scp,rsyncand-Lforwards work.Small related papercut:
colab sshlands you in/contentbut Colab exportsLD_LIBRARY_PATHonly into the kernel environment, sonvidia-smiin that shell fails withcouldn't find libnvidia-ml.soon a GPU runtime. The interactive remote command alreadycds; exporting/usr/lib64-nvidiathere costs one clause.Working implementations of all of the above, with tests, are on my fork if they are of any use:
https://github.com/Le-Anh-Duy/google-colab-cli
dev— the four Windows fixes plusattachfeat/attach—attachalone, offmainfeat/config-ssh— addsconfig-sshFull suite on Windows goes from 21 failed / 303 passed on
mainto 17 / 332 there; the 17 that remain are pre-existing and all Windows-related (prompt_toolkit, and twosshtests that hardcodeSIGHUP).Happy to open PRs if that ever becomes useful, or to leave it here.
All reactions