- An active LastPass account
- LastPass cli installed, see here
name
: my-super-secretusername
: my-super-secret-usernamepassword
: my-super-secret-password
lpass login <your LastPass username>
NOTE:
this will prompt you to enter your LastPass password
MY_SUPER_SECRET_USERNAME=`lpass show --username my-super-secret`
MY_SUPER_SECRET_PASSWORD=`lpass show --password my-super-secret`
Add the following code to the start of your script to ensure that LastPass always logs out even if the script errors:
function finish {
lpass logout -f
}
trap finish EXIT