According to my ssh_config
file...
Configuration data is parsed as follows:
- command line options
- user-specific file
- system-wide file
With that said, (and yes, I know, I could scour man ssh_config
AND man ssh
, and (hope) for documented defaults).. how can I "print out" the active configuration, for ALL current settings. For example, something like...
ssh -o Tunnel=ethernet servername -p 2210 --print-config
SSH-2.0-OpenSSH_7.0
Command Line Options
Port 2210
Host servername
Command Line Configurations
Tunnel Ethernet
Config File
...
SSH Defaults
...
AddressFamily any (???)
BatchMode no
...
This would let you know explicitly exactly what is set, and why. I called out AddressFamily
specifically, as it is a perfect example of a configuration option with NO documented default value. From man ssh_config
...
Specifies which address family to use when connecting. Valid arguments are
any
,inet
(use IPv4 only), orinet6
(use IPv6 only).
Ugh! Thanks for any constructive suggestions (not just a bunch of RTFM
's). ?
There is
-G
option in recent openssh, which behaves in similar way as-T
on server side.By calling
ssh -G host
you will get options used for connecting to specific host, which can be helpful for debugging conditional matches inssh_config
.Also setting more verbose log level (
-vvv
) can help with debugging config parser.The only potential downside of
-G
is that it dumps the entire set of variables for a given target host, which is useful for scripting but can be a little messy to visually sort through.I kludged together a quick-and-dirty AWK script to meet my needs; give it a fragment of a name found on a
Host
line, and it will print the configuration block as found in the.ssh/config
file. Keep in mind that (1) a Host line can have multiple entries on it, and (2) this does assume that configuration lines will be indented for each Host block. Also, the script does not print out any global options specified in the config file, because I didn't want those.There are approximately infinite improvements that could be made to this. True AWK masters can probably write it in about five total lines.