1 min read

YubiKey OTP generation from the command line

One less reason to leave your favorite place, the terminal!

One less reason to leave your favorite place, the terminal!

Install

macOS prerequisite:

brew install swig

Install ykman with pipx, the official YubiKey manager CLI application

pipx install yubikey-manager

Usage

To list all available accounts

ykman oath accounts list

Generating an access code for an account that’s called danthelion:daniel@arecadata.com

ykman oath accounts code "

You will be prompted to touch your YubiKey as usual and your code will be generated!

Touch your YubiKey ...

danthelion:daniel@arecadata.com 461489

You can wrap this in a shell function for easy access. Create as many functions as you would like for different accounts if needed.

yk-main () {    echo "Generating code for '

Add this to your .zshrc to be able to invoke it whenever you want via running yk-main. After touching your YubiKey your access code will be pasted to your clipboard automatically.