Since I seldom need the functionality provided by oathgen (a complete HOTP/TOTP implementation), I typically use goathgen. Goathgen is a simple TOTP library and command line executable written in Go. If all you need is Google Authenticator type one-time codes and like simple CLI programs, you may try it.
Executable usage examples
$ gpg -d encrypted-secret.txt | goathgen
$ cat plaintext-secret.txt | goathgen
Installation via Go
$ go get github.com/62726164/goathgen
To build and install the executable
$ cd main && go build -o goathgen
$ sudo mv goathgen /usr/local/bin
To use the library in your go program
Read main.go to see a simple example
To run unit tests against the library
$ go test -v
$ go test
- To use the goathgen executable with a PGP encrypted TOTP secret
- Obtain a hex or base32 encoded TOTP secret from your service provider.
- Encrypt the TOTP secret with your PGP key and save the encrypted secret in a file.
- Securely delete and overwrite the plain-text TOTP secret.
- Decrypt the TOTP secret and pipe the output to goathgen.
- goathgen only works in TOTP mode using these TOTP defaults
- Six digit codes
- 30 second time step
- If you need other OATH functionality, edit the goathgen source code.
- Run NTP when using goathgen.