How can I use SetEnv
in ~/.ssh/config
(and the same config on various systems), but not throw an error when ssh
is too old to support it?
I've tried adding a Match exec
statement to exclude that setting when ssh
is too old (OpenSSH < 7.8):
Host server.example.com webhost
User jacktose
HostName server239.example.com
Match host "server.example.com webhost" exec "ssh -V 2>&1 | sed -nE '/^OpenSSH_(7\.(8|9|\d\d+)|(8|9|\d\d+\.))/!{q7}'"
SetEnv LANG=C
But it seems like the SetEnv
line is parsed and throws an error anyway:
$ ssh -vvv anyhost
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017
...
debug2: checking match for 'host "server.example.com webhost" exec "ssh -V 2>&1 | sed -nE '/^OpenSSH_(7\\.(8|9|\\d\\d+)|(8|9|\\d\\d+\\.))/!{q7}'"' host anyhost originally anyhost
debug3: /home/jacktose/.ssh/config line 37: not matched 'host "anyhost"'
debug3: /home/jacktose/.ssh/config line 37: skipped exec "ssh -V 2>&1 | sed -nE '/^OpenSSH_(7\\.(8|9|\\d\\d+)|(8|9|\\d\\d+\\.))/!{q7}'"
debug2: match not found
/home/jacktose/.ssh/config: line 38: Bad configuration option: setenv
...
/home/jacktose/.ssh/config: terminating, 1 bad configuration options
Match
itself. All my instances are at least new enough to supportMatch
. – Jacktose Jun 23 '23 at 21:07