Skip to main content

Using a Session Key

The CLI will return both an export BSAFE_SESSION (Bash) and env:BSAFE_SESSION (PowerShell) command, including your session key when you unlock your safe using bsafe login with email and password or bsafe unlock. You can copy and paste the relevant entry to save the required environment variable.

With the BSAFE_SESSION environment variable set, bsafe commands will reference that variable and can be run cleanly, for example:

export BW_SESSION="5PBYGU+5yt3RHcCjoeJKx/wByU34vokGRZjXpSH7Ylo8w=="
bsafe list items

Alternatively, if you do not set the environment variable, you can pass the session key as an option with each bsafe command:

bsafe list items --session "5PBYGU+5yt3RHcCjoeJKx/wByU34vokGRZjXpSH7Ylo8w=="

The BSAFE_SESSION environment variable is only tied to the active terminal session, so closing your terminal window is equivalent to locking your safe. You can also destroy an active session key to lock your safe by running:

bsafe lock