diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-02 19:05:24 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2024-12-02 19:05:24 +0100 |
| commit | 60643f945cc58565a0ca8ee9f5ec554fa41bd0d9 (patch) | |
| tree | 968d7697c4d747ae4edecf553ec242ac4f7f5c65 /2fa | |
| parent | 778574d025cf7a23b386d8cb110e265dd334dfc2 (diff) | |
| download | scripts-60643f945cc58565a0ca8ee9f5ec554fa41bd0d9.tar.gz scripts-60643f945cc58565a0ca8ee9f5ec554fa41bd0d9.zip | |
added 2fa script
Diffstat (limited to '2fa')
| -rwxr-xr-x | 2fa | 21 |
1 files changed, 21 insertions, 0 deletions
| @@ -0,0 +1,21 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # 2-factor authentication based on oathtool | ||
| 4 | |||
| 5 | # Usage: 2fa service [time] | ||
| 6 | |||
| 7 | # Requires: secret, oathtool | ||
| 8 | |||
| 9 | secrets_folder="$HOME/box/secrets" | ||
| 10 | |||
| 11 | if [ -z "$1" ]; then | ||
| 12 | echo "usage: 2fa service [time]" | ||
| 13 | exit 1 | ||
| 14 | fi | ||
| 15 | |||
| 16 | if [ -n "$2" ]; then | ||
| 17 | t="-N $2" | ||
| 18 | fi | ||
| 19 | |||
| 20 | secret="$(secret show "$secrets_folder/$1-2fa")" | ||
| 21 | oathtool -b --totp "$secret" $t | ||
