0

I'm trying to figure out how to create persistant environment variables for my "root" user. I've tried running this in command line:

export ETSY_CONSUMER_SECRET='xxx'
export ETSY_CONSUMER_KEY='xxx'

If I then type:

echo $ETSY_CONSUMER_SECRET

I correctly get the value back. BUT as soon as I close the terminal and reload it, the variable is gone.

I then read you should add it to your /root/.bashrc file to make it persistant. So I added this there:

export ETSY_CONSUMER_KEY='xxx'
export ETSY_CONSUMER_SECRET='xxx'

reloaded the SSH connection, but I get nothing when doing:

echo $ETSY_CONSUMER_SECRET

I even tried just doing:

ETSY_CONSUMER_KEY='xxx'
ETSY_CONSUMER_SECRET='xxx'

But the same problem.

What am I missing?

  • 2
    Puth those in the /etc/environment file without the export keyword ythe it will be persistent – George Udosen Nov 24 '18 at 7:24
  • @GeorgeUdosen would that mean any other user can access them though? (they are API keys, so I don't want anyone else to be able to see them outside of the users I allow) – Andrew Newby Nov 24 '18 at 7:26
  • Ok that's true other users will access them. Now did you creat a seperate root user or the root user here is the one in the sudo group? – George Udosen Nov 24 '18 at 7:29
  • Thanks. This is just the standard root user (comes with the VestaCP setup). I guess its the sudo root as well. How would I check? – Andrew Newby Nov 24 '18 at 7:30
  • That user would have a passwd set for it so you could do a su root to switch to that account or do cat /etc/passwd | grep root and if you see an account then it's there! – George Udosen Nov 24 '18 at 7:32
1

Put them in the /etc/environment like so:

ETSY_CONSUMER_SECRET='xxx'
ETSY_CONSUMER_KEY='xxx'

Note theat the export keyword isn't added in this case. Now you should be able to use them whenever.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.