2FA at your fingertips

Here's the recipe to generate your favorite 2FA token without taking your hands off your keyboard.

Step 1

Store your login credentials and 2FA secret in a password manager like Bitwarden. https://bitwarden.com/help/password-manager-overview/

Step 2

Install Bitwarden CLI. https://bitwarden.com/help/cli/

Step 3

Login using bw login command and then export your Bitwarden Session Key BW_SESSION to an in-memory environment variable.

Step 4

Fetch the id of the record for which you want the 2FA token.

bw get item <credential name>

Step 5

Add the below lines to your .bashrc or .zshrc.

alias cp2fatoken="bw get totp <id from step 4> | pbcopy"

Step 6

Use cp2fatoken