Skip to content

fix(ssh-config): unquote Host aliases so ssh -G can resolve them - #95

Merged
Petyok merged 1 commit into
developmentfrom
feature/ssh-config-quoted-aliases
Aug 8, 2026
Merged

fix(ssh-config): unquote Host aliases so ssh -G can resolve them#95
Petyok merged 1 commit into
developmentfrom
feature/ssh-config-quoted-aliases

Conversation

@Petyok

@Petyok Petyok commented Aug 8, 2026

Copy link
Copy Markdown
Owner

What

Host "web" in ~/.ssh/config was listed as the alias "web" — quotes included — so resolve_host ran ssh -G '"web"' and got back hostname contains invalid characters. The host showed up in the list and could not be connected to. OpenSSH strips those quotes when matching; listable_host_alias now does too.

How it was found

By the first oracle test in the resolver: a differential test that takes every alias list_hosts() returns and resolves it through the real ssh binary, asserting it lands back on the block it came from. The alias parser is the one part of host resolution sshub implements itself — resolve_host already delegates to ssh -G, but OpenSSH has no "enumerate hosts" mode to delegate the listing to.

The nine existing unit tests for this parser all passed: they check the code against in-repo assumptions, which is exactly what does not catch an assumption that was wrong to begin with. The differential test failed on its first run, and was re-verified red against the unfixed parser before being called done.

Also in this PR

docs/oracle-tests.md writes the pattern down, with the subsystems that still have an unused external oracle:

Subsystem Oracle Status
ssh/resolver.rs alias listing ssh -G this PR
known_hosts.rs ssh-keygen -F / -R already done
ssh/export.rs round-trip the rendered snippet through ssh -G missing
ssh/keyfile.rs ssh-keygen -y / -l missing
import/{putty,mremoteng,termius_csv}.rs a real export from that tool fixtures are agent-authored

AGENTS.md and CLAUDE.md point at it.

How tested

  • just test — 671 + 73 + 44 + 1, all green, exit 0
  • cargo fmt --check, cargo clippy --all-targets — 0 warnings
  • New test verified red without the fix: ssh -G rejected listed alias "\"quoted\"": hostname contains invalid characters
  • The test skips itself when no ssh binary is present

🤖 Generated with Claude Code

Written by Claude Opus 5 (Claude Code) on behalf of the maintainer.

`Host "web"` was listed as the alias `"web"`, quotes included, so
`resolve_host` handed `ssh -G` a name it rejects with `hostname contains
invalid characters`: the host appeared in the list and could not be
connected to. OpenSSH strips those quotes; sshub now does too.

Found by a new differential test that resolves every alias `list_hosts`
returns through the real `ssh` binary — the alias parser is the one part
of resolution sshub implements itself, since OpenSSH has no way to
enumerate hosts to delegate to. The nine existing unit tests all passed
against in-repo assumptions; the differential test failed on first run.

Documents the pattern in docs/oracle-tests.md and points AGENTS.md /
CLAUDE.md at it, with the remaining subsystems that have an unused
external oracle (`ssh/export.rs`, `ssh/keyfile.rs`, the importers).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Petyok
Petyok merged commit cb9985a into development Aug 8, 2026
3 checks passed
@Petyok
Petyok deleted the feature/ssh-config-quoted-aliases branch August 8, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant