Basic configuration and use. (or read the longer version)
-
Install
lpass
, the LastPass command line interface. See installation instructions in its README file for Mac and Linux. For Windows, read the discussion on this feature request for a variety of options. -
In LastPass:
- Create an new folder called API_KEYS
- Create a new secure note template with a field called
Key
. It's pretty simple to do, but LastPass provides instructions for creating note templates if you need more help. (I took advantage of the consistency offered by custom note templates and use a template called "API Keys".)
-
Store your secrets in this new LastPass
API_KEYS
folder using this template. -
Add this to your
.bashrc
or.bash_profile
:# Use the email address associated with your LastPass account export LASTPASS_EMAIL="[email protected]" if type lpass 2>&1 >/dev/null && [[ -f $HOME/.lpassfunctions ]] then . $HOME/.lpassfunctions fi
Set environment variables from LastPass values like this:
set_env_var_from_lastpass ACME_KEY_ID
$ echo $ACME_KEY_ID
321decaf000bad
If you're feeling bold (or lazy), set all at once by adding this after you load .lpassfunctions
in your .bashrc
/.bash_profile
:
autoset_all_lastpass_keys