Created
August 22, 2019 21:09
-
-
Save derektamsen/a0cc171435dab9c54c34510232e7aa66 to your computer and use it in GitHub Desktop.
Configures a Google Authenticator TOTP in slot 2 on a yubikey for use on linux.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Ubuntu Installation | |
# - Install the ubuntu yubico ppa: sudo add-apt-repository ppa:yubico/stable | |
# - Update your apt cache: sudo apt update | |
# - Install the package for ykcalresp: sudo apt install yubikey-personalization | |
# - Copy the secret key below the qr code. | |
# - Run the gist and enter the secret key when prompted. | |
import base64 | |
import binascii | |
def decode_secret(secret): | |
secret = secret.replace(' ', '') | |
secret = secret.upper() | |
secret = secret.encode('ascii') | |
secret = base64.b32decode(secret) | |
return secret | |
def get_input(): | |
return raw_input('Google key: ') | |
def main(): | |
secret = decode_secret(get_input()) | |
encoded_key = binascii.hexlify(secret).decode('ascii').ljust(40, '0') | |
print('run the following command to update your yubikey') | |
print("ykpersonalize -2 -o chal-resp -o chal-hmac -o hmac-lt64 -o chal-btn-trig -a %s") % encoded_key | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment