Created
February 26, 2020 21:07
-
-
Save paulgreg/9fd6639a74e8e1e565022ffc02698ef5 to your computer and use it in GitHub Desktop.
A simple oathtool wrapper to generate second factor TOTP token stored in a gpg encrypted file
This file contains 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/bin/env bash | |
if [ -z $1 ]; then | |
echo | |
echo "Usage:" | |
echo " ./totp.sh service" | |
echo | |
echo "Configuration: $HOME/.totpkeys.gpg" | |
echo "File encoded with gpg" | |
echo "Format: service=key" | |
exit | |
fi | |
OTPKEY=$(gpg --decrypt $HOME/.totpkeys.gpg| sed -n "s/${1}=//p") | |
if [ -z "$OTPKEY" ]; then | |
echo "$(basename $0): Bad Service Name '$1'" | |
$0 | |
exit | |
fi | |
TIME=$(date +"%T") | |
echo -n "Code for $1 at $TIME : " | |
oathtool --totp -b "$OTPKEY" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment