Skip to content

Common OTP implementation in Shell, Python and Go

build your own 2FA/MFA app with Python, Go and Shell command.


import pyotp
totp = pyotp.TOTP('XXXXXXXX')


package main

import (


var (
    length = flag.Uint("length", otp.DefaultLength, "OTP length")
    period = flag.Uint("period", otp.DefaultPeriod, "Period in seconds")

func main() {

    tokenMap := make(map[string]string)
    tokenMap["sso token"] = "XXXXXXXXX"

    for keyName, keyToken := range tokenMap {
        totp := &otp.TOTP{
            Secret:         strings.ToUpper(keyToken),
            Length:         uint8(*length),
            Period:         uint8(*period),
            IsBase32Secret: true,
        fmt.Printf("%s: %s\n", keyName, totp.Get())


## Debian & Ubuntu
apt install oathtool

## Mac 
brew install oathtool

oathtool -b --totp XXXXXXXXX

  1. License under CC BY-NC 4.0
  2. Copyright issue feedback: dig +short txt
  3. Not all the commands and scripts are tested in production environment, use at your own risk
  4. No privacy information is collected here
Buy Me a Coffee