I am trying to store some environment variables for S3 in an encrypted shell script (so these keys aren't stored unencrypted on my drive) like so:
export AWS_ACCESS_KEY_ID="example_key_id"
export AWS_SECRET_ACCESS_KEY="example_secret_access_key"
This is saved as a shell script setenv.sh
which I've encrypted as setenv.sh.gpg
.
I'm trying to run the file script with eval $(gpg --decrypt ./setenv.sh.gpg)
which decrypts the file, but does not load the environment variables accordingly (a printenv confirms this).
I feel like it may have something to do with this question: Shell script to set environment variables
However, I've tried a number of different variations with source
to no avail as I assume source
expects a file and not the contents of a script.
How could I use a gpg encrypted shell script to set environment variables?