totpgen

command module
v0.0.0-...-b3759fd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2024 License: AGPL-3.0 Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

totpgen

Utility to generate TOTP tokens

Usage

The secret tokens are saved in the systems keychain (via 99designs/go-keychain).

To add a totp TOTP secret, run

totpgen set "<secret-name>" "totp-secret"
# eg
totpgen set google "SAucYHYJyfma1Fa6uFlBqzUluusgIj1slSwKRoVvhGYZsVCt"
totpgen set aws "44uHJtA8IwpKy9JjaaprSizgZ2TSImDY8iUPvm1qaDHReOTJ"

To generate the current OPT code run

totpgen google
# output:
123456

You can also create a symlink to the script and name it after totpgen-<name> (e.g. totpgen-google). Invoking the tool like this will also print the TOTP token for the specified name, no arguments required.

ln -sT totpgen totp-google
totp-google
# output:
123456

There are a couple more commands:

# show the names of saved totp configuration
totpgen list
# output:
google
aws

# to remove a secret use the 'set' command with an empty secret
totpgen set google ""

# rename a secret
totpgen rename google google-dev

# show available keychain backends
totpgen backends
# output
secret-service
kwallet
keyctl
pass
file

Installation

Via go install:

go install github.com/floj/totpgen
~/go/bin/totpgen --help

Manual

git clone https://github.com/floj/totpgen.git
cd totpgen
./build.sh
./totpgen --help
MacOS

I don't provide precompiled binaries, because past expirence showed that cross-compiled binaries for Mac do not properly work with the OSX keychain. Thus, if you want to use it on Mac, you need to compile it yourself using one of the above command.

Additionally available config options for MacOS
Environment variable Configuration Example
TOTPGEN_KEYCHAIN_NAME Name of the Keychain files used TOTPGEN_KEYCHAIN_NAME=totpgen-secrets

Why?

Main motivation was to use it in aws-vault. AWS Vault supports creating TOTP tokens via pass-otp. This is very nice, but limits you to use pass. I created a scriptmfa prompt provider (see genericscript.go) that is able to call whatever script you want. Just point it to totpgen-aws by setting AWS_VAULT_MFA_SCRIPT=totpgen-aws and you are good to go.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址