Ssh – How to show the host/configured/default ssh “configuration”

configurationdefaultsssh

According to my ssh_config file…

Configuration data is parsed as follows:

  1. command line options
  2. user-specific file
  3. 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), or inet6 (use IPv6 only).

Ugh! Thanks for any constructive suggestions (not just a bunch of RTFM's). 🙉

Best Answer

There is -G option in recent openssh, which behaves in similar way as -T on server side.

-G Causes ssh to print its configuration after evaluating Host and Match blocks and exit.

By calling ssh -G host you will get options used for connecting to specific host, which can be helpful for debugging conditional matches in ssh_config.

Also setting more verbose log level (-vvv) can help with debugging config parser.