Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neil-sabol/2b40ee8d178a9ee8b97fe6345c549ffc to your computer and use it in GitHub Desktop.
Save neil-sabol/2b40ee8d178a9ee8b97fe6345c549ffc to your computer and use it in GitHub Desktop.
See https://blog.neilsabol.site/post/yubikey-personalization-tool-yubico-powershell-command-cli-program-random-static-password-commandline/#closing-thoughts. This snippet uses the ykpersonalize (YubiKey Personalization Tool) command to generate a new static password on the Yubikey.
# Create an alias for ykpersonalize pointing the the location it is downloaded to
set-alias ykpersonalize "$env:localappdata\Programs\Yubico\bin\ykpersonalize.exe"
# Generate a random hex (AES key) to serve as entropy (randomness source) for ykpersonalize
$RandomHex = (((32)|%{((1..$_)|%{('{0:X}' -f (random(16)))})}) -Join "").ToLower()
# Run ykpersonalize to generate a random static password in Yubikey's config slot 2
ykpersonalize -2 -a"$RandomHex" -ostatic-ticket -oshort-ticket -ostrong-pw1 -ostrong-pw2 -y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment