Created
February 28, 2019 21:16
-
-
Save zdrummond/9d90827b9b4b9b877f02328843c7fbbd to your computer and use it in GitHub Desktop.
Command Line Two Factor
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
| ~/.otpkeys | |
| ---- | |
| aws={secret code} | |
| google={secret code} |
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
| $ otp aws | |
| 310645 |
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
| /usr/local/bin/otp | |
| ---- | |
| #!/usr/bin/env bash | |
| if [ -z $1 ]; then | |
| echo | |
| echo "Usage:" | |
| echo " otp google" | |
| echo | |
| echo "Configuration: $HOME/.otpkeys" | |
| echo "Format: name=key" | |
| exit | |
| fi | |
| OTPKEY=$(sed -n "s/${1}=//p" $HOME/.otpkeys) | |
| if [ -z $OTPKEY ]; then | |
| echo "$(basename $0): Bad Service Name '$1'" | |
| $0 | |
| exit | |
| fi | |
| oathtool --totp -b $OTPKEY |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool idea from: https://www.sendthemtomir.com/blog/cli-2-factor-authentication