Minimal CLI tool for generating 6-digit TOTP 2FA codes (RFC 6238). Zero dependencies — Go stdlib only.
Works with GitHub, Google, AWS, and any service that uses standard TOTP.
go install github.com/DabDavis/totp@latestOr build from source:
git clone https://github.com/DabDavis/totp.git
cd totp
go build -o totp .# Generate a code from a secret
totp YOURSECRETHERE
# 482931 (27s remaining)
# Or save the secret and run without args
echo 'YOURSECRETHERE' > ~/.totp && chmod 600 ~/.totp
totp
# Setup instructions
totp setup- Go to github.com → Settings → Password and authentication
- Click Enable two-factor authentication
- Click "setup key" under the QR code to get the base32 secret
- Run
totp <secret>and enter the 6-digit code on GitHub to verify - Download and save your recovery codes
- Save the secret for future use:
echo '<secret>' > ~/.totp && chmod 600 ~/.totp
TOTP is HMAC-SHA1 over a time-based counter (30-second intervals), truncated to 6 digits per RFC 4226. The entire implementation is ~40 lines of Go.