Skip to content
One-time Password generator for CLI using bash, oathtool
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.


One-Time Password generator for CLI using bash, oathtool.

Automatically copys the token into your computer's copy buffer (MacOS only atm)

This is basically "Authy for the CLI"

This script supports both encrypted and plain-text token files, but my reccomendation is to use encryption.



Set of bash shell scripts to generate OTP value from token using TOTP.


First ensure that there is a directory "tokenfiles" in the main dir where the script resides.

  1. Create token file and encrypt it. Resulting file, "tokenfiles/tokenname.enc", is an encrypted file containing the token
  2. Put your token in a plaintext file in the tokenfiles/ directory:
$ echo "1234567890abcdef" > tokenfiles/tokenname
  1. Encrypt the file with the included shell script:
$ ./ tokenfiles/tokenname
Password: (enter a good password)
  1. Confirm it worked:
$ ls tokenfiles/
  1. Run; will produce roughly the following output:
$ ./ tokenname
02: 123456

The number on the left is the seconds counter; a new TOTP token is generated every 30 seconds.

The number on the right is the 6-digit One-Time Password.

This will be copied directly into the paste buffer. Just press "Command-V" (or "CTRL-V" on Linux) to paste into a login dialog.


  • Script to do the actual value generation
  • Script to encrypt the token in a file
  • Script to decrypt same
  • Empty "tokenfiles/" directory
You can’t perform that action at this time.