What is the difference between ssh configuration file settings:

  • At the top (global) level
  • In a Host * scope?

Assuming there is a difference, in which cases would each be preferred?

1 Answer 1


The SSH configuration documentation touches on this indirectly:

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.

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.

So settings in the “top” level can’t be overridden, whereas settings in Host * will be overridden by any setting defined before that section (in the “top” level, or in a section matching the target host).

This answers “in which cases would each be preferred”: the “top” level should be used for settings which shouldn’t be overridden, and the Host * section, which should come last, should be used for default settings.

  • Does your answer effectively say "there's no difference except for hinting at please-don't-override-me settings"? (Unlessshouldn’t be overridden means can't be overridden)?
    – Tom Hale
    Aug 28, 2020 at 15:57
  • 2
    Right, my answer wasn’t quite clear enough; the top level should be used for settings which shouldn’t be overridden, because the top level settings can’t be overridden. Aug 28, 2020 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.