Skip to content

Instantly share code, notes, and snippets.

@wr0ngway
Created December 22, 2016 21:48
Show Gist options
  • Save wr0ngway/bc33acca4e8ae9c05553a43142e8827f to your computer and use it in GitHub Desktop.
Save wr0ngway/bc33acca4e8ae9c05553a43142e8827f 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