TOTP(1) Manual Page

  • Home
  • Back

  • TOTP(1) General Commands Manual TOTP(1)

    totpgenerate TOTP codes

    totp [-d digits] [-p period] [-u] [secret ...]

    totp is a utility to generate TOTP codes on the command-line. You can provide TOTP secret codes either through the standard input or as command-line. If you would like to use OTP URIs instead, those are also supported through the -u option, which enables URI parsing of inputs.

    When working with OTP URIs, metadata regarding the digit length or the duration period of TOTP codes is typically contained within the URI, and totp parses and interprets that information for you. This is not the case when using raw TOTP secret codes. When using TOTP secret codes, it is assumed that TOTP codes are 6 digits long with a duration of 30 seconds. If you need different defaults you can make use of the -d and -p flags.

    The options are as follows:

    , --digits=length
    Set the digit length of TOTP codes to length. If this flag is not specified, the digit length defaults to 6 digits.
    , --period=seconds
    Set the duration period of TOTP codes to seconds. If this flag is not specified, the duration period defaults to 30 seconds.
    , --uri
    Interpret input as OTP URIs instead of raw TOTP secret keys.

    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

    Get a TOTP code for an OTP URI:

    $ totp -u 'otpauth://totp/GitHub:Mango0x45?secret=7YNEG7J3XBIVYR54'

    The same as above, but extract the URI from a QR-code using zbarimg(1):

    $ zbarimg -q qr.png | sed 's/QR-Code://' | totp -u

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

    $ totp -d8 -p60 7KFSJ562KJDK23KD

    sed(1), zbarimg(1), HMAC(3ssl), SHA1(3ssl)

    Extended Description and -Documentation

    Thomas Voss <[email protected]>

    October 3, 2023 MangoOS