Categories

Category cover

Automation
43 posts

Category cover

Security
20 posts

Category cover

Notes
19 posts

Category cover

Personal Security
15 posts

Category cover

CISO
14 posts

Category cover

Infrastructure
12 posts

Category cover

Learning paths
9 posts

Category cover

OT/ICS
6 posts

Category cover

UNetLab
4 posts

Category cover

Books
3 posts

Category cover

Write-up
3 posts

Category cover

OSInt
2 posts

Category cover

My life
1 posts

Secured Bash environment

Andrea Dainese
August 14, 2022
Post cover

I always need to set critical environment variables on my Bash (API tokens), and of course, it’s a very bad idea to store them on .bashrc. I found a simple way to store them in an encrypted file loading it only when necessary:

  1. Store critical variables under .bash_secure (you must export each variable).
  2. Encrypt it with gpg -c .bash_secure.
  3. Secure delete the clear text file with shred -u .bash_secure.
  4. Load secured environment only when needed source <(gpg -q -d ~/.bash_secure.gpg)

Don’t put the load command into .bashrc because commands included in .bashrc must not emit output.