Files
ssh-protocol-handler-win/SshHandlerRs
Claude 1bd676d2fe Rebase Rust handler's protocol registration on the .bat's Default Apps model
The direct HKCR\ssh\shell\open\command write (what SshHandler and the
initial Rust port both did) doesn't actually get honored once a
UserChoice already exists for the ssh scheme, which is the normal
state on Windows 10/11 — so registration silently no-ops from the
user's perspective.

Switch to the same "Default Programs" capability registration
openssh_protocol_handler.bat uses: a dedicated ProgID with
Capabilities\UrlAssociations plus a HKLM\SOFTWARE\RegisteredApplications
entry, so the app actually shows up in and can be selected from
Settings > Apps > Default Apps > "Choose default apps by link type".
Uses its own identifier, ssh_handler_rs, distinct from the batch
script's ssh_custom_handler so the two don't collide.

Verified end-to-end under Wine: registry keys land exactly as
expected (checked via `wine reg query`), and both the setup and
connect dialogs still render correctly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GYCT2RpUjFfBfp6CD4rREw
2026-09-08 16:48:31 +00:00
..

ssh-handler (Rust)

A from-scratch rewrite of SshHandler (the .NET/WinForms ssh:// protocol handler) in Rust, targeting raw Win32 (via windows-rs) instead of a managed GUI framework. Same behavior, same registry keys, same dialog layout — just without the .NET runtime.

Why: the WinForms build's self-contained publish is ~150MB and pays CLR startup cost on every single ssh:// link click. This version has no runtime, no GC, no JIT — cold start is just process creation plus a native dialog box. Release build is ~250KB.

Building

Cross-compiling from Linux (what CI does):

rustup target add x86_64-pc-windows-gnu
sudo apt install mingw-w64
cargo build --release --target x86_64-pc-windows-gnu

Or natively on Windows with the MSVC toolchain:

cargo build --release

The dialog is a native Win32 resource (resources/ssh_handler.rc), compiled via embed-resource in build.rs — no GUI toolkit dependency.

Behavior

  • No arguments: setup mode. Checks for admin rights, confirms with the user, then writes the ssh:// protocol registration under HKEY_CLASSES_ROOT.
  • ssh://user@host argument: handler mode. Parses the target (defaulting the username to the current Windows user if omitted), shows a small dialog to confirm/edit the target and optionally enable "legacy mode" (older KEX/HostKey/MAC/cipher algorithms for old SSH servers), then launches ssh.exe -A -C ... user@host via ShellExecuteW.