bashshellsshterminal.env

How can I load a local config.env in an bash-file when executed remotely?


I have a local config.env which is called in a local local.sh. However, when I use a SSH connection to execute that file on a remote server it's not working anymore.


Example

config.env

HELLO="world"

local.sh

. config.env
printf "Test: %s\n" "$HELLO" # working

When executing ssh -T user@server 'bash -s' < ./local.sh it's not working anymore.


Solution

  • You can do :

    ssh -T user@server 'bash -s' < <(cat config.env local_as_remote.sh)
    

    and remove . config.env line from local_as_remote.sh