fix(ssh-config): unquote Host aliases so ssh -G can resolve them - #95
Merged
Conversation
`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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Host "web"in~/.ssh/configwas listed as the alias"web"— quotes included — soresolve_hostranssh -G '"web"'and got backhostname contains invalid characters. The host showed up in the list and could not be connected to. OpenSSH strips those quotes when matching;listable_host_aliasnow 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 realsshbinary, asserting it lands back on the block it came from. The alias parser is the one part of host resolution sshub implements itself —resolve_hostalready delegates tossh -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.mdwrites the pattern down, with the subsystems that still have an unused external oracle:ssh/resolver.rsalias listingssh -Gknown_hosts.rsssh-keygen -F/-Rssh/export.rsssh -Gssh/keyfile.rsssh-keygen -y/-limport/{putty,mremoteng,termius_csv}.rsAGENTS.mdandCLAUDE.mdpoint at it.How tested
just test— 671 + 73 + 44 + 1, all green, exit 0cargo fmt --check,cargo clippy --all-targets— 0 warningsssh -G rejected listed alias "\"quoted\"": hostname contains invalid characterssshbinary is present🤖 Generated with Claude Code
Written by Claude Opus 5 (Claude Code) on behalf of the maintainer.