Skip to content

Instantly share code, notes, and snippets.

@elliotwutingfeng
Created March 30, 2024 15:34
Show Gist options
  • Save elliotwutingfeng/a3ed47816a149fc1b9e345a4706e349d to your computer and use it in GitHub Desktop.
Save elliotwutingfeng/a3ed47816a149fc1b9e345a4706e349d to your computer and use it in GitHub Desktop.
One-liner Linux terminal command to generate TOTP code using oathtool (https://www.nongnu.org/oath-toolkit/oathtool.1.html)
#!/bin/sh
# SHA1, 30 seconds, 6 digits; the most common configuration.
# Adjust accordingly if your OTP credential uses different parameter values.
# Upon entering this command, type in your TOTP secret (it will not be echoed back to the screen), then press 'Enter'
stty -echo;oathtool --totp=SHA1 --time-step-size=30s --digits=6 --base32 -;stty echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment