Python package for managing Yubico OTP slots on YubiKeys.
Note
|
This project is no longer maintained. Please refer to https://github.com/Yubico/yubikey-manager for a more fully-featured and supported Python library for interacting with YubiKeys. |
The YubiKey is a hardware token for authentication. The main mode of the YubiKey is entering a one time password (or a strong static password) by acting as a USB HID device, but there are things one can do with bi-directional communication:
-
Configuration. The yubikey_config class should be a feature-wise complete implementation of everything that can be configured on YubiKeys version 1.3 to 3.x (besides deprecated functions in YubiKey 1.x). See
examples/configure_nist_test_key
for an example. -
Challenge-response. YubiKey 2.2 and later supports HMAC-SHA1 or Yubico challenge-response operations. See
examples/nist_challenge_response
for an example.
This library makes it easy to use these two features.
Here is a trivial usage example :
#!/usr/bin/env python
""" Get version of connected YubiKey. """
import sys
import yubico
try:
yubikey = yubico.find_yubikey(debug=False)
print("Version: {}".format(yubikey.version()))
except yubico.yubico_exception.YubicoError as e:
print("ERROR: {}".format(e.reason))
sys.exit(1)
If you use a recent Ubuntu release, you should be able to install python-yubico using apt-get:
$ sudo apt-get install python3-yubico