Bart
Bart

Reputation: 331

How SSH Environment Variables works with shell script file?

If I run the command bellow and my install.sh has the following section:

export S3_URL=$PRD_URL
export S3_ACCESS_KEY=$PRD_S3_ACCESS_KEY
export S3_SECRET_KEY=$PRD_S3_SECRET_KEY

cat install.sh | ssh $PRD_USER@$PRD_HOST

The $PRD_S3_ACCESS_KEY is going to be resolved from my host or the environment variables from the remote server?

Upvotes: 0

Views: 236

Answers (1)

Philippe
Philippe

Reputation: 26767

Assuming you have gettext installed (which contains envsubst), you can do

envsubst < install.sh | ssh $PRD_USER@$PRD_HOST

Upvotes: 2

Related Questions