Created
July 19, 2024 00:52
-
-
Save enif-lee/77460cc6da3c9c04c24026bfaea6c62e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bw_unlock() { | |
if ! bw unlock --check; | |
then | |
export BW_SESSION="$(bw unlock --raw)" | |
fi | |
} | |
function tsh_login() { | |
bw_unlock | |
password=$(bw get password <teleport-vault-name>) | |
otp=$(bw get totp <teleport-vault-name>) | |
user=<your_name> | |
if ! tsh status; then | |
expect -c " | |
spawn tsh login --proxy=teleport.iamport.co --user=$user --auth=local --mfa-mode=otp | |
expect { | |
-re \"Enter password for Teleport user $user:\" { | |
send -- \"$password\r\" | |
exp_continue | |
} | |
-re \"Enter an OTP code from a device:\" { | |
send -- \"$otp\r\" | |
} | |
} | |
interact | |
" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment