Skip to content

Instantly share code, notes, and snippets.

@fangpsh
Forked from wr0ngway/otp
Created June 14, 2021 01:44
Show Gist options
  • Save fangpsh/204f4dace96c20c8edf34ab47241cf94 to your computer and use it in GitHub Desktop.
Save fangpsh/204f4dace96c20c8edf34ab47241cf94 to your computer and use it in GitHub Desktop.
#!/bin/bash
# brew install oath-toolkit
#
# ~/.otpkeys:
# name1=secret
# name2=secret
scriptname=`basename $0`
if [ -z $1 ]
then
echo "$scriptname: Service Name Req'd"
echo ""
echo "Usage:"
echo " otp google"
echo ""
echo "Configuration: $HOME/.otpkeys"
echo "Format: name=key"
exit
fi
otpkey=` grep ^$1= $HOME/.otpkeys | cut -d"=" -f 2 | sed "s/ //g" `
if [[ -z $otpkey ]]; then
echo "$scriptname: Bad Service Name"
exit
fi
key=$(/usr/local/bin/oathtool --totp -b $otpkey)
printf $key | pbcopy
echo $key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment