Auto ssh login with bitwarden saved password & totp pin
- Will auto prompt for bitwarden login/unlock (using
bwof https://github.com/bitwarden/cli) - Get item from bitwarden with matching domain and auto fill password with
expect - Auto fill TOTP pin with
oathtoolcomputed result if available - Decode bitwarden json result with
node
- Only tested on ubuntu & bash
- Bitwarden session will be expired after current terminal session ended or any new
bw unlockexecution
bwof https://github.com/bitwarden/cliexpectof https://core.tcl-lang.org/expect/indexoathtoolof https://www.nongnu.org/oath-toolkit/nodeof https://nodejs.org/en/
git clone https://github.com/lessmind/bitwarden-ssh-auto-login.git
cd ~/bin/ # or any other dir in $PATH
ln -s /path/to/bitwarden-ssh-auto-login/bwsshAdd alias in .bashrc or other equivalent files
alias ssh='. bwssh ssh'
alias scp='. bwssh scp'
# or any other command requires ssh loginuse . for exporting BW_SESSION to current shell
Vim ~/.bwssh
# [ssh host] [bitwarden object id]
# comment starts with '#'
ssh1.example.com 00000000-0000-0000-0000-000000000001
ssh2.example.com 00000000-0000-0000-0000-000000000002
ssh3.example.com 00000000-0000-0000-0000-000000000003[bitwarden object id] could be obtained from bw list, see bw list --help