Could any expert please solve my confusion? ;)
I'm just trying to consolidate my .ssh/config and as things still
aren't working as expected, I'm not sure if I understood the way the
config is parsed. What I want to achieve is a setup where a
destination can hit more than one configuration block and I thought
that "match host" applies some settings but continues parsing whereas
"host" is a final statement.
As an example, with the following config file,
===== 8< =====
match host networkA,networkB
forwardAgent yes
user u1
host hostA
user u2
===== >8 =====
"ssh hostA" with an IP address in networkB is supposed to actually do
"ssh -A -l u2 hostA". But I don't see a difference between "match
host" and "host", both directives seem to be final and it looks like
the "first match" policy doesn't apply to entire "host" blocks but to
every single option, hence preventing any option from being
overwritten.
IS this right? How does the config have to look like for the desired
result?
On 26.11.22 17:26, Eric Pozharski wrote:
First, my reading of ssh_config(5) suggests that neitherI'm still not sure if I really gut what you want to say here.
"configuration block", nor "conditional block", nor "block" is
canonical.
Now, what ssh(1) does if multiple blocks match is a mistery --
ssh_config(5) doesn't tell anything. I believe options are:
[1] first
[2] last
[3] random
[4] merge (with options [1]..[3] applied (recursively?))
[5] none
[6] none and bail out
Looks like [5] and [6] are out. From what you describe, I can't pickI can supply some output if you like but I'm afraid this won't be very helpful. "-v" only shows which file is being used but not what's
among [1]..[4] -- excerpts of 'ssh -v' output are required (but not
requested, it's up to you).
happening behind the scenes - and "-G" only show the result of all
this. I've also been wondering which of there options may apply but I couldn't find an answer. Another possibility (even if most probably
also wrong) could be "best".
I expect (pessimisticaly), it will end up with least (I'd go withI hope you're wrong (please don't take that personal ;). Currently, I
most) specific pattern per host with desired options -- one block for
each host that's where it's going :/
have a couple of "host" blocks with name patterns. In most cases, this
works as expected but it's far from cool.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 486 |
Nodes: | 16 (2 / 14) |
Uptime: | 146:01:08 |
Calls: | 9,659 |
Calls today: | 1 |
Files: | 13,708 |
Messages: | 6,167,917 |