Last active
September 20, 2022 07:02
-
-
Save 3735943886/64a3fc797c908a1b4408aec59b136ef3 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
#!/usr/bin/env bash | |
LOGINUSER="$(who am i | awk '{print $1}')" | |
HOMEDIR="$(getent passwd $LOGINUSER | cut -d: -f6)" | |
OTPKEY="$HOMEDIR/.otpkeys" | |
RCX=0 | |
echo | |
if [ -f "$OTPKEY" ] | |
then | |
while read -r services; do | |
if [ -z $1 ] || [[ "${services%=*}" =~ $1 ]] | |
then | |
((RCX++)) | |
printf "${services%=*} : " | |
oathtool --totp -b "${services#*=}" | |
fi | |
done < "$OTPKEY" | |
fi | |
if [ $RCX -eq 0 ] | |
then | |
echo "Usage:" | |
echo " $0 google" | |
echo | |
echo "Configuration:" | |
echo " $OTPKEY" | |
echo | |
echo "Format:" | |
echo " name=key" | |
fi | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment