Install USB card reader

I had to use a USB CardReader (Omnikey 5421) in a course. This device will not work out of the box (at least not in Ubuntu 15.10 64-bit) so you will have to do some *magic* described in this post...

OS-Selection: I will use a plain-vanilla Ubuntu 15.10 64-bit as guest OS, but this should work on every Debian based Linux-Distribution (proviging apt-get support and a half-decent actual package repository). For other Linux distros you will have to use another package manager (e.g. yum) and find the right packages or compile them on your own (not recommended).
Attention: You will need a 64bit host-system to virtualize a 64bit virtual machine (ref).

Requirements

This tutorial describes how to install and use the card reader on a Ubuntu installation. So if you are a Mac user (like me) or just have Windows installed, you should install a virtual machine first. VirtualBox is free and quite good, but I am using Parallels Desktop, which is not expensive but provides better host/gest-integration and IMHO performs slightly better.

Now you have to configure that the virtual machine has access to your USB-devices. VirtualBox users will find a short step-by-step tutorial here.

For Parallel do the following: I assinged my USB device permanently to the vm. You can do the same with Paralell just by opening the vm-specific settings, navigate to hardware, select USB & Bluetooth and click on USB Connection Preferences.... Then a new window opens immediatly and you can add such an assignment:

Install dependencies, driver and tools

First of all boot your vm (depends on your vm-provider). In ubuntu you have to install PCSC-Lite, which needs libusb and libscsclite inclusive development dependencies. pcscd is the daemon and the pcsc tools provides a few nice command line tools (e.g. pcsc_scan and gscriptor):

sudo apt-get install libusb-1.0-0-dev libpcsclite-dev pcscd pcsc-tools

I used the following lines to compile and install pcsclite:

wget https://alioth.debian.org/frs/download.php/latestzip/112/ccid-latest.zip
cd ~/Downloads
unzip ccid-latest.zip
tar -xvf ccid-*
cd ccid-*
./configure
make
sudo make install
sudo cp src/92_pcscd_ccid.rules /etc/udev/rules.d/

Now you have to download the device specific driver. Go to hidglobal drivers, select Omikey as your device vendor and Linux x64 as target platform. Then you should get a list with a lot of entries.. The right one is named something like this "OMNIKEY 5x2x PC/SC for Linux 64Bit". Download it and open a terminal and copy/paste the following commands:

cd ~/Downloads
tar -xvf ifdokrfid_lnx_x64-*
cd ifdokrfid_lnx_x64-*
sudo ./install

Now it's time for a reboot (This may not be mandatory, but I always reboot my machine after a successful driver installation).

Test it

Back in Ubuntu you can use the lsusb command to test if the device is visible:

parallels@ubuntu:~/Downloads/ccid-1.4.21$ sudo lsusb
Bus 001 Device 007: ID 203a:fff9  
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 076b:5421 OmniKey AG 
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Now you have to restart the service...

sudo service pcscd restart

... and scan for devices (you will have to put your decive out and in again). If the output looks like this, it works:

pcsc_scan

Ready steady go!

Now you can open gscriptor, which provices a nice GUI for issuing ISO 7816-4 APDU-commands to the reader (the specific device can be selected in the settings).