Skip to content

Instantly share code, notes, and snippets.

@ccampo133
Created August 8, 2019 02:41
Show Gist options
  • Save ccampo133/8fba87470c9dda22159fe57644c5a9c4 to your computer and use it in GitHub Desktop.
Save ccampo133/8fba87470c9dda22159fe57644c5a9c4 to your computer and use it in GitHub Desktop.
Generate an MFA TOTP token. Secret keys are stored in your ~/.mfa directory
#!/usr/bin/env bash
#
# Generate an MFA TOTP token. Secret keys are stored in your ~/.mfa directory
#
# Requires oathtool: http://www.nongnu.org/oath-toolkit/man-oathtool.html
#
# Example: I might have the following...
# $ cat ~/.mfa/aws.mfa
# ASDLJGJ893AS7JJF83NLSD9RTSMF81NSLA85SNSA81MASNFHG75KAKSKJV0192F7
#
# ...and then running like so would produce something like:
# $ mfa aws
# 789102
#
oathtool --base32 --totp "$(cat ~/.mfa/"$1".mfa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment