How can I save environment variables (sensitive) in gopass and retrieve them and set in my bash terminal them from command line.
I know this can be done in 1password where the password are stored:
myaccount
Internally this is in json format and can be pull with a command like:
op get item "myaccount" | jq .
source <(op get item ${1} | jp -r --arg key2 "${2} '.details.section[] |
select(.title==$title) | .fields[0].v' | base64 -D ")
The whole idea is my environment variables must be set in a automate way from a secure vault rather than me exporting them like this:
export key1=value1
export key2=value2
export key3=value3
This is a bit of a late answer, but you could save them into gopass like this:
echo $key1 | gopass insert store/environment/key1
Or if you need them to be base64 ecoded:
echo $key1 | base64 -w 0 | gopass insert store/environment/key1
Then you could source them still using export
, but sourcing them from gopass, rather than hard coding them.
key1=$(gopass store/environment/key1)
key1=$(gopass store/environment/key1 | base64 -d)