Goathgen
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
or
$ go test
Notes
- 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
- HMAC-SHA1
- Six digit codes
- 30 second time step
- If you need other OATH functionality, edit the goathgen source code.
- Read the C++ oathgen source code for full OATH functionality
- https://github.com/62726164/oathgen
- Run NTP when using goathgen.