Skip to content

Windows: fix generated SSH ProxyCommand launch and missing SIGHUP cleanup signal #178

Closed

Description

@lw-liuwang

Problem

Native Windows support is already tracked in #85, and the original startup/file-locking fixes have landed (#53, #135, #158). On current main (006ff96), two remaining failures in commands/ssh.py prevent the generated SSH transport from working reliably on Windows:

  1. _proxy_command() uses shlex.join(). Windows OpenSSH launches its ProxyCommand with Windows process argument rules, so POSIX single quotes around a Python path are treated literally. A Python installation under a path containing spaces fails to launch (CreateProcessW / file-not-found).
  2. _install_rm_signal_handlers() directly evaluates signal.SIGHUP, which does not exist on Windows. colab ssh --proxy-mode --rm raises AttributeError before reaching the bridge.

The local UserKnownHostsFile is also hardcoded to /dev/null; it should use the local platform's null device.

Environment and reproduction

  • Native Windows 11 (build 26200), PowerShell, Python 3.12.14, Windows OpenSSH.
  • Base commit: 006ff96 on upstream main.
  • Offline signal reproduction, requiring no credentials or runtime:
uv run python -c "from colab_cli.commands.ssh import _install_rm_signal_handlers; _install_rm_signal_handlers(lambda: None)"

Result: AttributeError: module 'signal' has no attribute 'SIGHUP'.

For the command-launch failure, generate _proxy_command() with an interpreter installed under Python with spaces, then execute it as a Windows command line. The generated command starts with a POSIX-single-quoted executable path and fails to launch. The accompanying PR includes both real child-process tests and a real Windows OpenSSH ProxyCommand launch test using a local stub, without allocating Colab resources.

Proposed scoped fix

  • Use subprocess.list2cmdline() on Windows, retaining shlex.join() and its security tests on POSIX.
  • Register only signals available on the current platform.
  • Use os.devnull for the local known-hosts sink.
  • Run the SSH regression suite on Windows, Linux, and macOS.

The 22 added regression cases fail before these fixes. With the fixes and coverage for both colored and plain help output, the SSH suite passes all 115 cases on native Windows. The full Windows suite changes from 21 failed / 333 passed / 2 skipped to 15 failed / 362 passed / 2 skipped. The remaining failures were reproduced before the change (help-output parsing, temporary-file editing, and headless REPL construction).

Live Colab validation passed on 2026-10-20: the native Windows integration script created one CPU runtime, used Windows OpenSSH and the generated ProxyCommand to execute a remote marker command with an identity path containing spaces, and released the recorded endpoint. The final CLI sessions query reported no active assignments. Windows/Linux/macOS SSH CI also passes. This is a step toward Windows support, not a claim of complete platform support.

Related work

Implementation: #181

Windows support plan: #180

The command-quoting diagnosis was previously documented by @Le-Anh-Duy in discussion #97. This issue gives the remaining SSH work a focused, testable scope. Related broader efforts: #85, #86, #167 and discussion #83. The existing termios and select-on-pipe fixes are not being reimplemented here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions