TOTP(1) General Commands Manual TOTP(1)

totpgenerate TOTP codes

totp [-d digits] [-p seconds] [secret ...]

totp is a utility for generating TOTP codes. If no secret is provided as a command-line argument, secret keys are read newline-separated from the standard input.

The options are as follows:

digits
Specify the length in digits of the generated TOTP codes. The default digit value is 6.
seconds
Specify the duration for which the generated TOTP codes are valid. The default seconds value is 30.

The totp utility exits 0 on success, and >0 if an error occurs.

Get TOTP codes for two different secret keys using the standard input:

$ printf '7KFSJ562KJDK23KD\n7YNEG7J3XBIVYR54' | totp

The same as the above but using command-line arguments:

$ totp 7KFSJ562KJDK23KD 7YNEG7J3XBIVYR54

Generate an 8 digit TOTP code that is valid for 60 seconds:

$ totp -d8 -p60 7KFSJ562KJDK23KD

uri2totp(1)

Thomas Voss <mail@tvoss.eu>

April 26, 2026 TOTP 3.0