Mailing List Archive

Compounding global and individual settings in ssh-config files?
Hello everyone,

my workplace has gotten the idea of centrally maintaining a file in
ssh_config syntax so that employees do not need to discover every new
machine and configure it on their own. Since it's a case of "let's get
started now, and properly think it through later", right now, a typical
entry might look like

> Host [product]-[Customer]
> Hostname [privateIP]
> user [primaryAccount]
> ProxyCommand nc -x 127.0.0.1:2124 -X 5 %h %p

(with the parts in [] varying from one machine to the next) - and if you
know how disparate the options of "nc"/netcat can look from one distrib
to the next, you'll immediately know why this suggestion has me
concerned. :-}

I suppose that *this* particular instance of the problem can be mostly
fixed, either by switching to "ProxyJump" (referring to a config entry
that every user maintains himself) or with a wrapper script¹, but it has
me wondering: Are there plans, or even better already-implemented
mechanisms, that would allow entries in (global) config files to
"inherit"² single config lines preset in another (individual) config file?

¹ Note that as of now, the names do *not* include which platform the
machine is running on, but the proper proxying depends on that. So, no
using "Host" blocks with patterns unless I can get everyone to using
*my* host-naming style. :-/

² Please take the term with a planetoid of salt. I do not have a
preference whether it should be, or act like, "inheritance" like in
Nagios object configs, "includes", "variables", "templates", or
whatever. :-3

³ Yes, I suppose that providing just the main data - name, IP, user,
port (if nonstandard) and which proxy to use - from a central source and
individually turning that into an ssh_config with some preprocessor
could also prove a powerful solution here ...

Thanks in advance,
--
Jochen Bern
Systemingenieur

Binect GmbH
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
> On Mar 28, 2024, at 13:24, Jochen Bern <Jochen.Bern@binect.de> wrote:
>
> ?[ProxyCommand with 'nc'...] if you know how disparate the options of "nc"/netcat can look from one distrib to the next, you'll immediately know why this suggestion has me concerned. :-}

I may be misremembering or completely wrong, but isn't 'ssh -W' intended to be a replacement for 'nc' in ProxyCommands?
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
> On Mar 28, 2024, at 13:24, Jochen Bern <Jochen.Bern@binect.de> wrote:
>
> ?[ProxyCommand with 'nc'...] if you know how disparate the options of "nc"/netcat can look from one distrib to the next, you'll immediately know why this suggestion has me concerned. :-}

I may be misremembering or completely wrong, but isn't 'ssh -W' intended to be a replacement for 'nc' in ProxyCommands?
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
On Thu, Mar 28, 2024 at 09:16:56PM +0100, Jochen Bern wrote:
> ...
> Are there plans, or even better already-implemented mechanisms,
> that would allow entries in (global) config files to "inherit"? single
> config lines preset in another (individual) config file?
>...

Check the `Include` section of the ssh_config manpage

-c
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
On Fri, 29 Mar 2024 at 07:58, Jim Knoble <jmknoble@pobox.com> wrote:
> I may be misremembering or completely wrong, but isn't 'ssh -W' intended to be a replacement for 'nc' in ProxyCommands?

It is, but only for the vanilla usage ("ProxyCommand ssh jumphost nc
%h %p"), not using it to connect via a SOCKS5 proxy as shown in the
example config above. ssh(1) does not natively support connecting via
SOCKS.

--
Darren Tucker (dtucker at dtucker.net)
GPG key 11EAA6FA / A86E 3E07 5B19 5880 E860 37F4 9357 ECEF 11EA A6FA
Good judgement comes with experience. Unfortunately, the experience
usually comes from bad judgement.
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
On Thu, 28 Mar 2024, Jochen Bern wrote:

> I suppose that *this* particular instance of the problem can be mostly fixed,
> either by switching to "ProxyJump" (referring to a config entry that every
> user maintains himself) or with a wrapper script¹, but it has me wondering:
> Are there plans, or even better already-implemented mechanisms, that would
> allow entries in (global) config files to "inherit"² single config lines
> preset in another (individual) config file?

This isn't exactly what you asked for, but you might be able to solve
this problem using Tag / match tagged, but it involves almost the
opposite of inheritance.
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
On 28.03.24 23:02, chris wrote:
> On Thu, Mar 28, 2024 at 09:16:56PM +0100, Jochen Bern wrote:
>> Are there plans, or even better already-implemented mechanisms,
>> that would allow entries in (global) config files to "inherit"² single
>> config lines preset in another (individual) config file?
>
> Check the `Include` section of the ssh_config manpage

Well, if we didn't have "Include", mixing one's .ssh/config out of
globally-maintained and local/individual files (without using some
preprocessor) would be a nonstarter ...

... wait. Do you mean to replace every single "ProxyCommand nc ..." line
in the global file with an "Include my_proxying_oneliner_for_site_XYZ"?

[runs test]

(... OK, need to keep that one-liner in a subdir disjunct from the
*existing* wildcard "Include"s, and "Include" takes pathes relative to
~/.ssh, not relative to the file where the "Include" occurs ...)

It *works*, but I wonder how *scalable* that approach is, with read()s
zig-zagging between config files like a March hare ... ?

Kind regards,
--
Jochen Bern
Systemingenieur

Binect GmbH
Re: Compounding global and individual settings in ssh-config files? [ In reply to ]
On 29.03.24 05:36, Damien Miller wrote:
> On Thu, 28 Mar 2024, Jochen Bern wrote:
>> Are there plans, or even better already-implemented mechanisms, that would
>> allow entries in (global) config files to "inherit"² single config lines
>> preset in another (individual) config file?
>
> This isn't exactly what you asked for, but you might be able to solve
> this problem using Tag / match tagged, but it involves almost the
> opposite of inheritance.

Well, it's the kind of inheritance you see with a *very eager* heir of
somebody rich, effectively shouting "gimme" ... ;-)

I'd be calling it a first-rate match for my request *if only* I weren't
running Fedora 39:

> $ ssh -V
> OpenSSH_9.3p1, OpenSSL 3.1.1 30 May 2023

while tags were introduced with 9.4 ... but I'll have a look at tags,
and the OpenSSH versions other colleagues have at their disposal, for sure!

Kind regards,
--
Jochen Bern
Systemingenieur

Binect GmbH