[Bug 3841] Configuration parser is broken

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Mon Jun 23 09:53:46 AEST 2025


https://bugzilla.mindrot.org/show_bug.cgi?id=3841

Darren Tucker <dtucker at dtucker.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dtucker at dtucker.net

--- Comment #1 from Darren Tucker <dtucker at dtucker.net> ---
(In reply to Vitali Falileev from comment #0)
> A preceding 'Host' entry prevents a subsequent 'Include' directive
> from working  [...]
> This behavior is incorrect, as a non-matching `Host` entry should
> not affect the processing of subsequent directives in the
> configuration file.

The man page says otherwise.

> Host example
>     HostName 127.0.0.1
>     User admin
>     Port 2222
> 
> Include ~/.ssh/config.d/*.conf

Your indentation makes it look like the Include is in a separate block,
but indentation is not and has never been syntactically significant. 
Quoth ssh_config(5):

Host    Restricts the following declarations (up to  the  next  Host 
or
        Match  keyword) to be only for those hosts that match one of
the
        patterns given after the keyword.

What you wrote is equivalent to 

Host example
    HostName 127.0.0.1
    User admin
    Port 2222
    Include ~/.ssh/config.d/*.conf

The behaviour of Include inside Host or Match blocks is described in
ssh_config(5):

"Include  directive  may  appear inside a Match or Host block to
 perform conditional inclusion."

> Placing the `Include` directive(s) as the very first line in
> ~/.ssh/config allows the configuration to be parsed correctly.

You can also put a "Host *" at the top of the included file to make the
Include contents apply to all hosts.  Depending on how you structured
the file, it could have surprising results if you *do* want to use it
inside a Host or Match block.

-- 
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list