User Tools

Site Tools


docu:chseet:ofsec:sec:otp_comand_line

Use TOTP on *nix command line


It is surely really handy to be able to generate TOTP codes on the command line, as it can be used either as a secure client, or by integrating it on a custom service.

Instructions for Debian-based Linux's, (adapt it to your needs)

apt-get install oathtool
 
# save the secrets somewhere
echo 'SECRET_FOR_AMAZON' > ~/.otp/amazon
echo 'SECRET_FOR_PROTONMAIL' > ~/.otp/proton
 
# create the current time code by file output
cat ~/.otp/amazon | xargs oathtool --totp --base32
cat ~/.otp/proton | xargs oathtool --totp --base32
 
# (optionally), you can copy directly to clipboard without cat'ing it
# by using the xclip tool (apt-get install xclip)
cat ~/.otp/proton | xargs oathtool --totp --base32 | xclip -rmlastnl -i /dev/stdin


Have a QR code on the screen and don't know how to copy the secret value manually?? unless the service gives you the ability to copy the secret directly, you won't be able to do so.

Follow the other guide i made about QR code image handling so you can save the secret for creating codes on the command line later.

docu/chseet/ofsec/sec/otp_comand_line.txt · Last modified: 2020/08/17 09:34 by admin