I am trying to execute a script on a remote host through SSH. The script uses environment variables that are set on the local shell. The variables in the script are not expanded.
ssh user@host 'bash -s' < script.sh
#!/bin/bash docker pull "$IMAGE"
On the remote host this is executed as:
docker pull ""
As indicated by the error output:
Error parsing reference: "" is not a valid repository/tag: repository name must have at least one component
I've tried to use command substitution:
ssh user@host < $(cat script.sh)
Which leads to:
bash: line 95: $(cat script.sh): ambiguous redirect
How can I make the variables in
script.sh expand before passing the commands over SSH?