~/.ssh/config Host Pattern Matching Rules

Created On: 2016-02-02

If you happen to use host pattern matching in ~/.ssh/config, you may be interested in the pattern matching rules. It's documented in ssh_config man page.

man ssh_config

ssh(1) obtains configuration data from the following sources in the following order:

  1. command-line options
  2. user's configuration file (~/.ssh/config)
  3. system-wide configuration file (/etc/ssh/ssh_config)

For each parameter, the first obtained value will be used. The configuration files contain sections separated by “Host” specifications, and that section is only applied for hosts that match one of the patterns given in the specification. The matched host name is the one given on the command line.

Since the first obtained value for each parameter is used, more host-specific declarations should be given near the beginning of the file, and general defaults at the end.

Is this post helpful?