Skip to content

Support Match tagged in ssh_config - #51

Open
ajchemist wants to merge 1 commit into
alebeck:mainfrom
ajchemist:match-tagged
Open

ajchemist wants to merge 1 commit into
alebeck:mainfrom
ajchemist:match-tagged

Conversation

@ajchemist

Copy link
Copy Markdown

Problem

OpenSSH supports a Tag directive and a matching Match tagged <pattern>
criterion (see ssh_config(5); ssh -P <tag> sets the tag from the command line).
boring's parser rejects tagged as an unsupported Match keyword:

(1, 7): unsupported Match keyword "tagged"

Since parse errors are returned from ssh_config.ParseSSHConfig, a single
Match tagged block anywhere in ~/.ssh/config (or an included file) makes
every tunnel fail to open, including tunnels for unrelated hosts. The same
config works fine with ssh(1).

Change

  • Accept tagged as a Match keyword.
  • Track the tag in matchContext, set by the first Tag directive in a
    matching block (first value wins, like User/HostName already are).
  • Match tagged matches against that tag. boring has no equivalent of
    ssh -P, so without a Tag directive the tag is empty and, like
    ssh(1) with no tag set, Match tagged does not match.

No new config options or dependencies; the change is 11 lines in the parser
plus a testdata file.

Tests

New testdata/match-tagged cases in TestGet:

  • host with Tag work picks up the Match tagged work block
  • a second Tag line does not override the first
  • host without a tag falls through to Host *

make test passes except TestConfigCreateOpenFails, which fails the same
way on main when run as root (the read-only directory is still writable).

Notes

Match exec and Match canonical remain unsupported; this PR only covers
tagged, which can be evaluated without running commands or DNS lookups.

OpenSSH added the Tag directive and the "Match tagged" criterion.
The parser rejected "tagged" as an unsupported Match keyword, so a single
"Match tagged" block anywhere in ~/.ssh/config made every tunnel fail to
open.

Accept "tagged" and match it against the first Tag set by a preceding
matching block, like ssh(1). boring has no equivalent of ssh -P, so
without a Tag directive the tag is empty and "Match tagged" never
matches, which is also what ssh(1) does when no tag is set.
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