- code
- bash
- knowledge-backup
- yubikey
- cli
- tiny-helpers
I have used a Yubikey as the primary way of managing my OTP codes for several years now. I usually use the Yubico Authenticator application, which is great. But, sometimes when I am working in my editor and terminal I just want to stay there.
So I wrote this little wrapper around ykman
to make my life a bit easier. It is very simplistic, but it gets the job done for me. To use, just make sure it is executable and in your path, then you can just type something like otp github
and it will stick the code into your clipboard, assuming you have xclip
installed.
#!/bin/bash
# alias pbcopy="xclip -sel clip"
if [ -z "$1" ]
then
echo 'need account name '
exit 1
else
CODE=$(ykman oath accounts code $1 | awk '{print $NF}')
fi
echo $CODE | xclip -sel cli
The only error checking this does is check to ensure you pass an account name. If you have multiple accounts that match your account name, things will be weird. I also do not think this will handle codes that require touch.