Repository navigation
feat(doctor,install): probe sshd readiness + scope strict-probe to python (PR #153 follow-up) - #156
Conversation
…s + scope ssh-stub probe to python only
Joel's directive 2026-04-27: "Both need to host so just part of doctor
and/or install" — Windows users need sshd to host airc rooms, but
Windows ships OpenSSH client only (server is opt-in capability since
Win10 1809). Pre-fix: install printed "All required prereqs present"
against a Windows install with no sshd; airc doctor probed for ssh
client only. First cross-machine pair silently failed at the
ssh-tail step.
## Changes
### `airc doctor` — new `_doctor_probe_sshd` per-platform
- **macOS**: launchctl + `systemsetup -getremotelogin` for the Remote
Login state. Fix hint: System Settings -> Sharing -> Remote Login.
- **Linux/WSL**: `systemctl is-active` on `ssh` (Debian/Ubuntu unit
name) and `sshd` (RHEL/Fedora). Fix hints for both pkgmgrs.
- **Windows-bash**: `powershell.exe -Command "(Get-Service sshd
-ErrorAction SilentlyContinue).Status"` distinguishes:
Running → ok
Stopped/StopPending/StartPending/Paused → BROKEN with start hint
empty → MISSING with Add-WindowsCapability hint
- **Other**: info-level skip; doesn't penalize.
### `install.sh` — same probe at install time
Same per-platform branches; warn-only (no auto-install since
elevation needed on Windows). User runs the printed PowerShell
commands once, re-runs installer, sshd is up.
### `_doctor_probe` — scope strict-probe to python only (BUG REGRESSED FROM PR #153)
The PR #153 strict-probe applied `--version` to ALL binaries. macOS BSD
ssh-keygen exits 1 on `--version` ("illegal option"), so doctor false-
positived [BROKEN] on every Mac. The new sshd probe surfaced this
regression on its first run (clean Mac doctor output revealed the
stale [BROKEN] ssh-keygen line).
Fix: only python and python3 have shadow-aliases on Windows
(Microsoft Store stubs). Other binaries are uniquely shipped by the
user's package manager — bare `command -v` is correct + portable.
## Why this matters
"Both need to host" — the airc design assumes every peer is a
first-class host candidate. Pre-fix Windows users discovered they
COULDN'T host until they hit it the hard way (peers can't connect,
no diagnostic). Post-fix, install + doctor surface it immediately
with the exact admin-PowerShell commands.
## Test posture (Mac regression)
- part_persists: 8/8
- list: 4/4
- general_sidecar_default: 12/12
- platform_adapters: 11/11
- airc doctor live: 7/7 prereqs ok, 1 sshd MISSING (this Mac has
Remote Login off — correctly flagged with the macOS-specific fix).
## Out of scope
`airc.ps1` should also gain an equivalent probe + install.ps1 should
auto-install + start sshd when run elevated. Queued for Windows
iteration step 3.
There was a problem hiding this comment.
Pull request overview
Adds an sshd (SSH server) readiness probe to prevent cross-machine pairing failures where the SSH client exists but the SSH server is absent/not running (notably on Windows), and fixes a macOS regression introduced by PR #153’s blanket --version probing.
Changes:
- Add a per-platform
sshdreadiness probe toairc doctor(anddoctor --connect) with fix hints. - Add a warn-only
sshdreadiness probe toinstall.shwith fix hints. - Scope strict
--versionprobing in_doctor_probetopython/python3to avoid false failures on BSD/macOS utilities (e.g.,ssh-keygen).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
install.sh |
Adds warn-only sshd detection and platform-specific remediation hints during prereq checks. |
airc |
Adds _doctor_probe_sshd and integrates it into doctor / doctor --connect; adjusts _doctor_probe strictness to python only. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if ! systemctl is-active --quiet ssh 2>/dev/null && ! systemctl is-active --quiet sshd 2>/dev/null; then | ||
| warn "sshd not running — needed when you HOST a room." | ||
| warn " Debian/Ubuntu: sudo apt-get install openssh-server && sudo systemctl enable --now ssh" | ||
| warn " RHEL/Fedora: sudo dnf install openssh-server && sudo systemctl enable --now sshd" |
There was a problem hiding this comment.
On Linux this assumes systemd is available. If systemctl is missing (common in minimal containers, Alpine/openrc, some WSL setups), both systemctl is-active checks will fail and we’ll warn that sshd isn’t running even though we can’t actually probe. Please guard with command -v systemctl and either skip the sshd check (info-only) when absent or add an alternate probe for non-systemd init systems.
| if ! systemctl is-active --quiet ssh 2>/dev/null && ! systemctl is-active --quiet sshd 2>/dev/null; then | |
| warn "sshd not running — needed when you HOST a room." | |
| warn " Debian/Ubuntu: sudo apt-get install openssh-server && sudo systemctl enable --now ssh" | |
| warn " RHEL/Fedora: sudo dnf install openssh-server && sudo systemctl enable --now sshd" | |
| if command -v systemctl >/dev/null 2>&1; then | |
| if ! systemctl is-active --quiet ssh 2>/dev/null && ! systemctl is-active --quiet sshd 2>/dev/null; then | |
| warn "sshd not running — needed when you HOST a room." | |
| warn " Debian/Ubuntu: sudo apt-get install openssh-server && sudo systemctl enable --now ssh" | |
| warn " RHEL/Fedora: sudo dnf install openssh-server && sudo systemctl enable --now sshd" | |
| fi | |
| else | |
| info "Skipping sshd service-state probe on Linux: systemctl not available." |
| MINGW*|MSYS*|CYGWIN*) | ||
| # Windows Git Bash: probe via powershell.exe. | ||
| if command -v powershell.exe >/dev/null 2>&1; then | ||
| _SSHD_STATE=$(powershell.exe -NoProfile -Command "(Get-Service sshd -ErrorAction SilentlyContinue).Status" 2>/dev/null | tr -d '\r\n ') | ||
| case "$_SSHD_STATE" in | ||
| Running) ok "sshd running (OpenSSH.Server service)" ;; | ||
| Stopped|StopPending|StartPending|Paused) | ||
| warn "sshd installed but not running (state: $_SSHD_STATE) — needed when you HOST." | ||
| warn " Run in admin PowerShell:" | ||
| warn " Start-Service sshd" | ||
| warn " Set-Service sshd -StartupType Automatic" | ||
| ;; | ||
| "") | ||
| warn "sshd NOT installed — needed when you HOST a room." | ||
| warn " Run in admin PowerShell (one-time):" | ||
| warn " Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0" | ||
| warn " Start-Service sshd" | ||
| warn " Set-Service -Name sshd -StartupType Automatic" | ||
| warn " Then re-run install.sh." | ||
| ;; | ||
| esac | ||
| fi |
There was a problem hiding this comment.
Windows probe only runs if powershell.exe is on PATH. In Git Bash environments where only PowerShell Core is available as pwsh.exe, this will silently skip sshd detection. Consider the same fallback used in airc (pwsh.exe when powershell.exe is missing) so install warnings are consistent.
| ;; | ||
| MINGW*|MSYS*|CYGWIN*) | ||
| # Windows Git Bash: probe via powershell.exe. | ||
| if command -v powershell.exe >/dev/null 2>&1; then |
There was a problem hiding this comment.
_SSHD_STATE is assigned without local inside ensure_prereqs, which leaks a global variable into the script environment under set -u/set -euo pipefail conventions. Make it a local to avoid accidental reuse/collision with other logic in this script.
| if command -v powershell.exe >/dev/null 2>&1; then | |
| if command -v powershell.exe >/dev/null 2>&1; then | |
| local _SSHD_STATE |
| linux|wsl) | ||
| # Debian/Ubuntu uses 'ssh', RHEL/Fedora/Arch uses 'sshd'. | ||
| if systemctl is-active --quiet ssh 2>/dev/null || systemctl is-active --quiet sshd 2>/dev/null; then | ||
| printf " [ok] sshd (systemd active)\n" | ||
| return 0 | ||
| fi | ||
| printf " [MISSING] sshd -- needed when you HOST a room\n" | ||
| printf " Fix (Debian/Ubuntu): sudo apt-get install openssh-server && sudo systemctl enable --now ssh\n" | ||
| printf " Fix (RHEL/Fedora): sudo dnf install openssh-server && sudo systemctl enable --now sshd\n" | ||
| return 1 |
There was a problem hiding this comment.
The linux/wsl branch treats systemctl as authoritative. On hosts without systemd (Alpine/openrc, some containers, many WSL installs without systemd enabled), systemctl will be missing and this will incorrectly report [MISSING] sshd and block airc doctor --connect, contradicting the function contract (“don’t penalize if we can’t tell”). Please check command -v systemctl first and return an [info] sshd probe skipped (or implement a non-systemd probe) when it’s unavailable.
…needs to be in the install" gap) (#157) feat(install): auto-install + start sshd during install (close architectural gap) Joel's directive 2026-04-27 (via continuum-b69f relay through coord gist): > "if we can prompt the user, we do NOT have them do annoying setup > shit we automate into install, which gets what it needs done, no > later interaction and definitely not MORE after first install. and > detect via doctor if missing. and tell them how to remedy." Translation: 1. install.{sh,ps1} does end-to-end setup with elevation prompts (ONE elevation moment during first install). No separate post-install steps for the user to remember. 2. airc doctor is drift detection — catches when something flipped off after install. Already done in PR #156. 3. Remedy commands are AI-runnable — doctor's output is a contract with the user's AI. Already done in PR #156. Missing piece (this PR): install.{sh,ps1} should actually RUN the missing prereq commands during install, not just probe + report. ## Changes ### install.sh — `_ensure_sshd_running` Per-platform, idempotent (no-op if already running): - **macOS**: probes Remote Login state (launchctl/systemsetup); if off, runs `sudo systemsetup -setremotelogin on` with one sudo prompt. - **Linux**: probes systemctl (Debian's ssh and RHEL's sshd unit names); if missing, installs openssh-server via the platform's package manager + enables-and-starts the right unit. - **Windows-bash**: probes via `powershell.exe Get-Service sshd`; if missing or stopped, self-elevates via `powershell.exe Start-Process -Verb RunAs` with all three commands inline (Add-WindowsCapability + Start-Service + Set-Service Automatic) → ONE UAC prompt for the user. \`AIRC_SKIP_SSHD=1\` short-circuits for headless CI / config-managed environments. ### install.ps1 — `Install-OpenSSHServer` Mirrors the bash logic for the native Windows installer. Probes Get-Service sshd, then Get-WindowsCapability for state. Three commands: Add-WindowsCapability, Start-Service, Set-Service Automatic. Catches admin-required errors and prints the manual fallback (same shape as existing Install-OpenSSHClient). Hooked into the install flow right after Install-OpenSSHClient. ## Idempotency Both install.sh and install.ps1 short-circuit if sshd is already Running. Re-running install.sh on a working box doesn't re-prompt for sudo or UAC. Same for install.ps1. ## Test posture (Mac regression) - part_persists: 8/8 - list: 4/4 - general_sidecar_default: 12/12 - platform_adapters: 11/11 ## Out of scope End-to-end Mac↔Windows substrate test once both sides have sshd up (parallel work; not blocked on this PR).
…g (PR #156/#157 live-test followups) (#158) fix(sshd-probe): macOS detection without sudo + osascript admin dialog when non-interactive Two issues found while running PR #157 live on Mac 2026-04-27: ## Bug 1: launchctl list (user scope) doesn't show system services Pre-fix probe: ```bash launchctl list 2>/dev/null | grep -q "com\.openssh\.sshd" ``` Bare `launchctl list` is user-scope. Returns user-launched LaunchAgents only — never system-level launchd jobs like com.openssh.sshd. The fallback `systemsetup -getremotelogin` requires sudo to read state. Net: doctor reported `[MISSING] sshd` even when Remote Login was fully enabled and active sshd-session processes were forking. Fix: `launchctl print system` (no sudo needed) lists system services including com.openssh.sshd when Remote Login is on. Anchor regex on service-id boundary so we don't false-positive on per-connection session subkeys (com.openssh.sshd.<UUID>) which exist transiently even when Remote Login is just toggling. ## Bug 2: install.sh sudo path fails in non-interactive contexts When install.sh runs from a Monitor-spawned shell or curl|bash pipe, no TTY is attached. `sudo` then says "a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helper." Same problem as Joel hit running this from his Claude Code Bash tool. Fix: detect TTY presence (\`[ -t 0 ] && [ -t 1 ]\`); if interactive, use sudo. If not, fall through to osascript with the native macOS admin GUI dialog (with a branded prompt explaining what airc is doing — Joel 2026-04-27 relay through continuum-b69f). ## Live verification Pre-fix doctor on this Mac (Remote Login enabled live via osascript): ``` [MISSING] sshd -- needed when you HOST a room ``` Post-fix: ``` [ok] sshd (Remote Login enabled) ``` ## Same probe in install.sh The Darwin branch of \`_ensure_sshd_running\` now: - detects via launchctl print system (matching doctor) - splits sudo (TTY) vs osascript (non-interactive) for the elevation - both paths print airc-branded explanation in the admin prompt
…gnosis — sshd bind EPERM) (#160) fix(install,doctor): Windows HNS port-22 reservation + firewall rule (continuum-b69f diagnosis) Bug found by continuum-b69f mid-Windows-bringup 2026-04-27: \`Start-Service sshd\` failed with "Cannot bind any address" / permission denied even with admin. Root cause: Windows HNS (Host Network Service — backs Hyper-V, WSL2, Docker Desktop) dynamically reserves port ranges at boot. The reservations rotate per-boot and are NOT visible in \`netsh int ipv4 show excludedportrange\` (which only shows static admin reservations). When port 22 randomly falls inside an HNS-held range, sshd's bind() returns EPERM at OS level, regardless of admin status. Sources: - https://keasigmadelta.com/blog/how-to-solve-cannot-bind-to-port-due-to-permission-denied-on-windows/ - https://github.com/docker/for-win/issues/3171 - https://gist.github.com/strayge/481a77d31a94e133a76662877b1a90ca ## Persistent fix (this PR) Two-step persistent workaround applied during admin-elevated sshd install. Both ops idempotent — re-run of install on a healthy box doesn't re-prompt or duplicate state. 1. \`reg add HKLM\\SYSTEM\\CurrentControlSet\\Services\\hns\\State /v EnableExcludedPortRange /d 0 /f\` Disables HNS auto-exclusion. Survives reboots. 2. \`netsh int ipv4 add excludedportrange protocol=tcp startport=22 numberofports=1\` Explicitly reserves port 22 in the static excluded-port-range so HNS can't grab it on subsequent boots. Plus a New-NetFirewallRule for the OpenSSH-Server-In-TCP rule (the capability install usually creates it but it can be missing/disabled on some systems — idempotent check before creating). ## Files changed - \`install.ps1\` — \`Set-HnsPortFreedomFor22\` helper + wired into \`Install-OpenSSHServer\`. Native Windows installer path. - \`install.sh\` — Windows-bash branch's \`_ensure_sshd_running\` now emits a single elevated PowerShell payload that runs ALL the steps (capability install + HNS workaround + firewall rule + start + persist) so Joel/users click UAC ONCE for the whole sshd setup. - \`airc doctor\` — \`[MISSING] sshd\` Windows hint now includes the reg+netsh lines and explains why (HNS quirk). User can run all five commands as a contiguous block to remediate manually. ## Why this matters Pre-fix, even after the user ran the Add-WindowsCapability + Start- Service incantation from PR #156's hint or PR #157's auto-install, they could STILL hit the bind-EPERM if HNS happened to claim port 22 on their boot. Random failure, no diagnostic, looks like a permission bug. Continuum-b69f's diagnosis turns this from an unsolvable random into a one-time install action. ## Test posture (Mac regression) Mac side unchanged behavior; HNS branch only fires on MINGW/MSYS/CYGWIN. - part_persists: 8/8 - list: 4/4 - general_sidecar_default: 12/12 - platform_adapters: 11/11 ## Out of scope Cross-machine substrate end-to-end test once continuum's Windows host binds port 22 successfully. Parallel work; not blocked on this PR.
…nd-to-end (#177) fix(msys): export MSYS2_ARG_CONV_EXCL at airc startup — last layer of cross-machine fix (continuum's catch + verify) continuum-b69f's diagnosis 2026-04-27: even with PR #174 + #176's argparse `--flags`, MSYS Git Bash on Windows translates argv VALUES that look like Unix-rooted paths when bash invokes a Windows-native binary. So `--host-airc-home /Users/joelteply/.airc` arrived at python.exe as `--host-airc-home C:/Program Files/Git/Users/joelteply/.airc`, the joiner cached the corrupted path, the SSH command later sent it to a real Unix host that had no such file. Silent broadcast failure. ## Fix ```bash export MSYS2_ARG_CONV_EXCL="${MSYS2_ARG_CONV_EXCL:-/Users/;/home/;/root/}" ``` Set once at airc startup, exported, every airc_core invocation inherits the same translation policy. Targeted prefix list covers macOS / Linux / root home prefixes without breaking `/tmp/` or `/c/` paths (which DO need translation for `--config "$CONFIG"` where $CONFIG is on the local Windows filesystem). Honors a user override via the `${...:-...}` default-fallback. ## End-to-end verification continuum-b69f shipped a test broadcast from Windows after their local patch: > WORKING TEST: Windows-Mac airc msg via continuum-msyspatch with > targeted MSYS exclude. should land! Verified live in MY host's messages.jsonl on Mac: ``` {"from":"continuum-msyspatch","to":"all","ts":"2026-04-27T23:30:13Z", "msg":"WORKING TEST: Windows-Mac airc msg via continuum-msyspatch with targeted MSYS exclude. should land!","sig":"..."} ``` **Cross-machine Mac↔Windows airc end-to-end working.** This was the last bug in the chain that started at PR #153 (Microsoft Store python3 stub). ## Test posture (Mac, where the env var is a no-op) - tabs 19/19, identity 19/19, whois 5/5, part_persists 8/8, list 4/4, general_sidecar_default 12/12, kick 12/12, events 5/5, platform_adapters 11/11, whois_cross_scope 6/6 ## Today's full chain of cross-machine fixes #153 → #154 → #155 → #156 → #157 → #158 → #159 → #160 → #162 → #164 → #165 → #166 → ... → #176 → this. 27+ PRs to ship a working cross-machine airc on Windows. Every step revealed a new layer.
Why
Joel 2026-04-27: "Both need to host so just part of doctor and/or install."
airc design assumes every peer is a first-class host candidate. Windows ships OpenSSH client but not server (server is opt-in capability since Win10 1809). Pre-fix install printed "All required prereqs present" against a Windows install with no sshd; airc doctor probed ssh client only. First cross-machine pair silently failed at the ssh-tail step.
What
`airc doctor` — new `_doctor_probe_sshd`:
`install.sh` — same probe:
`_doctor_probe` regression fix (from PR #153):
Live test (Mac doctor output)
```
[ok] git
[ok] gh
[ok] gh authenticated
[ok] openssl
[ok] ssh
[ok] ssh-keygen
[ok] python3
[MISSING] sshd -- needed when you HOST a room
Fix: System Settings -> General -> Sharing -> Remote Login (toggle on)
Or: sudo systemsetup -setremotelogin on
[info] tailscale (optional) -- not installed; only needed for cross-LAN mesh
```
This Mac has Remote Login OFF — correctly flagged.
Mac regression
Out of scope
`airc.ps1` and `install.ps1` should grow equivalent probes + auto-install when elevated. Windows iteration step 3.