I'm trying to execute a script in SSH, and pass some params to that script. I've tried the following which didn't work - the value is not passed:
$ LC_FOO=x ssh -o SendEnv=LC_FOO $HOST < myLongScript.sh
The target hosts are sometimes very strict and recreated regularly so changing SSH settings on them is futile.
So I'm trying to resort to a trick and pass the value within the script itself. In other words, I want to append the variables to the script.
I've also tried these other approaches:
# doesn't work - 'ambiguous redirect'
$ ssh ... < $(...)
# doesn't work - 'LC_FOO=x: command not found'
$ $(echo "FOO=x"; cat myLongScript.sh) | ssh ...
How can I prepend the line on ssh
's input?
LC_FOO=x ssh -o SendEnv=LC_FOO
should have worked I think - provided the server side'sAcceptEnv
is set appropriately of course. Did you try something simple likeLC_FOO=x ssh -o SendEnv=LC_FOO user@remotehost 'printenv LC_FOO'
? – steeldriver Jul 10 '18 at 01:36/etc/ssh/ssh_config
and/etc/ssh/sshd_config
haveSendEnv LC_*
andAcceptEnv LC_*
respectively so actually for me it wasn't even necessary to add the-o SendEnv=LC_FOO
– steeldriver Jul 10 '18 at 02:34