Quick Ubuntu guide

$ sudo add-apt-repository ppa:yubico/stable
sudo apt-get update
sudo apt-get install python-pyhsm
pydoc pyhsm
pydoc pyhsm.base


python-pyhsm has been tested on Windows with Python 2.6 (2.7 will probably also work) from

You need to install pySerial (tested with pyserial-2.5.win32.exe) from

When you first insert the YubiHSM in your computer, Windows will indicate it cannot install the hardware. Download the .INF file from and select that in the Windows dialog.

Now, you should be able to communicate with the YubiHSM from Python like this (for this simple test, I put a copy of the pyhsm source tree in Z:\tmp\pyhsm):

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append("Z:\\tmp\\pyhsm")
>>> import pyhsm
>>> hsm = pyhsm.YHSM(device = "COM3")
<YHSM_Cmd_System_Info instance at 0x191a148: ver=(0, 9, 8), proto=1, ...>

Here is how to for example get five bytes of random binary data from the YubiHSM:

>>> hsm.random(5)
>>> hsm.random(5).encode("hex")