0

As I was reviewing my current OpenSSH client configuration file and intensively reading the ssh_config(5) man page, I found that, from my understanding, both Match all and Host * will achieve the same result.

Thus I was wondering if the fact that they cover the same need is a side effect of other usage for both Match and Host block, or if there are subtle differences between the two?

Edit:

After reading the answer to the question 741771 (thank you @muru for your proposal), I still have some doupt:

In it, @BlockchainOffice first say that:

The Match all block matches all hosts and is equivalent to Host *.

I understand that as "they can be used in the exact same way". However, later he adds:

How is Match All different to Host *?

Host * matches all hosts, thus the configuration directives that follow will be applied to all hosts. The hostname can appear anywhere in the pattern you use (either as part of the pattern itself, or at the end after an asterisk).

A "Match All" keyword is used to group all the configuration directives that apply to a particular host. When you use "Match All", you don't need to specify a pattern, as it will match all hosts by default.

And now I’m a bit lost. The two paragraphs seems to say they are different, but I don’t understand how. Mainly I don’t get the "The hostname can appear anywhere in the pattern you use (either as part of the pattern itself, or at the end after an asterisk)." about the Host *. I’m not sure what the hostname here is refering to and how it can appears in the pattern (what pattern?) or after the asterisk.

Étienne
  • 1
  • 1
  • 2
    One edge case: https://unix.stackexchange.com/questions/741771/in-ssh-config-what-does-match-canonical-all-mean – muru Jun 16 '23 at 11:36
  • You can have lines like `Host * !special-server`, or `Host !special-server *` to exclude certain hosts. That's a case where you have hostname patterns in addition to the `*`. – muru Jun 16 '23 at 23:28
  • Ho, maybe my question was not clear. When I asked for the difference between `Host *` and `Match all` I was speaking of exactly those lines. Not about `Host * something` or `Match something all`. But just exactly `Host *` and `Match all`. Said otherwise, when it comes to have a `Match all` or `Host *` configuration set, can we use any of the two as if they were exactly the same (and that’s just a matter of taste), or is there a little something, which will push us to use one instead of the other? – Étienne Jun 18 '23 at 07:39
  • If it's exactly those two, then yes, there's no difference. Both these ways exist because they can be used in combination with other things in different ways – muru Jun 18 '23 at 11:46
  • Thank you. That was what I thought and try to say with "the fact that they cover the same need is a side effect of other usage for both Match and Host block". You can change your comment as an answer to let me flag it if you want :) – Étienne Jun 19 '23 at 07:20

0 Answers0