Bug 3519 - Command line parameter to print out full config
Summary: Command line parameter to print out full config
Status: NEW
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 9.1p1
Hardware: All All
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-11 07:59 AEDT by Clarence "Sparr" Risher
Modified: 2023-01-13 13:04 AEDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Clarence "Sparr" Risher 2023-01-11 07:59:49 AEDT
~/.ssh/config can contain directives such as Include which result in a configuration state that cannot be found in any single file. `ssh -G [host]` will print out the fully processed config for a particular host, but information such as host wildcards cannot be authoritatively determined through this mechanism.

This enhancement request is for a command line parameter that will print the entire configuration after it is loaded. Ideally in a format that could be used as a standalone ~/.ssh/config, and with the contents matching the layout of the original included config files, but some other consistent and machine readable format would still be useful.

My use case involves some existing helper scripts that check for the existence of some configuration in ~/.ssh/config. Those scripts cannot see that configuration in my ~/.ssh/configX which is included in my main config, but I also don't want them to search ~/.ssh/* because that would cover files that aren't included or otherwise loaded. As I found myself considering writing my own ssh config preprocessor based on readconf.c I decided this request might be in order.

Example:
% cat ~/.ssh/config
Host foo
    HostName foo.foo.foo
Include configA
Include configB
% cat ~/.ssh/configA
Host bar
    HostName bar.bar.bar
% cat ~/.ssh/configB
Host foo
    User foouser
% ssh --print-config-ideal
Host foo
    HostName foo.foo.foo
Host bar
    HostName bar.bar.bar
Host foo
    User foouser
% ssh --print-config-acceptable
Host foo
    HostName foo.foo.foo
    User foouser
Host bar
    HostName bar.bar.bar
Comment 1 Darren Tucker 2023-01-13 13:04:14 AEDT
What you're asking for does not currently exist with ssh(1) and I don't think adding it would be easy.

The current parser builds up what its notion of the "full set" of options based on the arguments it's given, but that full set (the Options struct) is what is output by ssh -G, and it doesn't really have a notion of the "fully expanded" config for all hosts that you're asking for.