Add bwunlock.sh
This commit is contained in:
parent
550ad332f3
commit
ad480f6362
18
README.md
18
README.md
@ -1,2 +1,20 @@
|
|||||||
# bitwarden-helper-scripts
|
# bitwarden-helper-scripts
|
||||||
|
|
||||||
|
These are just some helper scripts I put together to help when using the official Bitwarden CLI.
|
||||||
|
|
||||||
|
## bwunlock.sh
|
||||||
|
|
||||||
|
Used to unlock a bitwarden vault and set the appropriate environment variables to keep the vault unlocked.
|
||||||
|
|
||||||
|
### Usage Instructions
|
||||||
|
|
||||||
|
1. Copy the file to a location of your choosing, I use `/home/$USER/scripts`
|
||||||
|
|
||||||
|
2. Set the following alias in your `~/.bashrc`:
|
||||||
|
```alias bw-unlock="source /home/$USER/scripts/bwunlock.sh"```
|
||||||
|
|
||||||
|
3. Source your bashrc or close and re-open your shell
|
||||||
|
|
||||||
|
4. Run `bw-unlock` and imput your Bitwarden Master Password when prompted
|
||||||
|
|
||||||
|
5. Run any Bitwarden command to ensure the script worked, like `bw list items`
|
||||||
|
19
bwunlock.sh
Executable file
19
bwunlock.sh
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# To unlock and set session vars for bitwarden vault
|
||||||
|
unset BWPASSWORD
|
||||||
|
prompt="Enter Bitwarden Master Password: "
|
||||||
|
while IFS= read -p "$prompt" -r -s -n 1 char
|
||||||
|
do
|
||||||
|
if [[ $char == $'\0' ]]
|
||||||
|
then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
prompt='*'
|
||||||
|
BWPASSWORD+="$char"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
|
||||||
|
export BW_SESSION="$(bw unlock $BWPASSWORD --raw)"
|
||||||
|
echo "Bitwarden vault unlocked, session variable set"
|
||||||
|
echo
|
||||||
|
unset BWPASSWORD
|
Loading…
Reference in New Issue
Block a user