Fix SSH config parsing failure when Match directive precedes Host blocks#212
Draft
Copilot wants to merge 2 commits into
Draft
Fix SSH config parsing failure when Match directive precedes Host blocks#212Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Complexity | 2 medium |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Agent-Logs-Url: https://github.com/TeddyHuang-00/sshping/sessions/dd3825c9-df43-4ee0-8990-76cf24cdf732 Co-authored-by: TeddyHuang-00 <64199650+TeddyHuang-00@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix ssh configuration parsing error with Match directive
Fix SSH config parsing failure when Match directive precedes Host blocks
May 2, 2026
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.
russh-configdoes not support theMatchkeyword — encountering it before the firstHostblock causes the parser to returnHostNotFound, making sshping fail entirely. MovingMatchdirectives to the end of the file was the only workaround.Changes
strip_match_blocks(contents: &str) -> String— preprocesses raw SSH config content by dropping everyMatchline and all option lines belonging to that block (up to the nextHostorMatchkeyword). Comments and blank lines inside Match blocks are also dropped.parse_config_path(path, host, context)— wraps file reading +strip_match_blocks+russh_config::parse(). Replaces all threeparse_path()call-sites (main config, jump host config, ProxyCommand config).Example config that previously failed
The
Matchblock and its settings are stripped before being handed torussh-config, leaving validHost-only content to parse.