|
Grimoire /
PAM-pkcs11
System Log-On using a SmartCardIf you use PAM, you have the ability to change how a linux system authenticates each user. We can use a SmartCard as a login token by using pam_pkcs11. Depending on your environment, it may work wonderfully, or alternatively can be viewed as a bit of a hack... You need:
Setting up pam_pkcs11 SmartCard Authentication
> pkcs11-tool -O [...snip...] Certificate Object, type = X.509 cert label: User certificate ID: 01 [...snip...] because if you don't get something like this, then there's not much point in continuing...!
>ls -la /etc/pam_pkcs11 drwxr-xr-x 2 root root 141 2008-12-31 05:51 . drwxr-xr-x 2 root root 141 2008-12-31 05:51 .. -rw-r--r-- 2 root root 141 2008-12-31 05:51 map_cn -rw-r--r-- 2 root root 141 2008-12-31 05:51 pam_pkcs11.conf -rw-r--r-- 2 root root 141 2008-12-31 05:51 pkcs11_eventmgr.conf
Once you have this stage sorted, then you can continue and get system-authentication configured. Event HandlerBefore configuring PAM, I am going to set up the Event Handler included with pam_pkcs11. Part of can't help thinking that this would probably be better configured via HAL and/or DBUS, but as I am not particularly knowlegable, I'll make do with the tools to hand. > pkcs11_eventmgr debug nodaemon should recognise card insert & disconnect events. If you remembered to ammend the commands, you might even get a sound with each event. We now have a couple of methods to influence a running system. Configuring PAM.The magic line to include in each /etc/pam.d/* file that you wish to influence the login behaviour of, is: auth sufficient pam_pkcs11.so
generally pretty much at the top. Console Login
Login unxer X11
Mouse clicks & Keyboard events normal = click (to confirm username) followed by password, then enter or click. \\ smartcard = click (confirm user), click (card inserted, confirm user), click (welcome to card, confirm user), enter PIN, enter or click. \\ Cannot use pkcs11-eventmgr, other than to kill it (which is probably the kindest option).
Usagepam_pkcs11 performs Login Autodetect. In other words, when the get_user() function returns either a NULL or an empty string, pam_pkcs11 will, rather than matching a Smartcard certificate with a named user, will instead find the Username with the matching certificate credentials. Unfortunately, while this is rather slick (as it potentially obviates the need to supply redundant user input), it is also where things begin to look a little hacked, since there are few smartcard-aware login-utilities. Therefore, we either:
All this is a great pity, and appears at first glance to defeat some of the claimed advantages of PAM. "That was in the beginning. Since then, a number of new ways of authenticating users have become popular. Including more complicated replacements for the /etc/passwd file, and hardware devices Smart cards etc.. The problem is that each time a new authentication scheme is developed, it requires all the necessary programs (login, ftpd etc...) to be rewritten to support it." (pam-FAQ) Only now, we appear to have a situation where each time a new authentication scheme is developed, we need to patch all the other applications that handle the login process! Increasing Security.The above set-up, although functional, is not particularly wonderful for a multi-user environment. For a single sign-on, with one token only, it's not so bad - what we have done is to replace the Username/Password combo with a Smartcard/PIN mechanism, where it is pretty hard to duplicate the Smartcard. However, for multiuser environments, there are a few more things we can do ... (I will illustrate using the NHS Smartcard as an example - so don't follow the steps below unless this is what you have! Adapt accordingly.) Checking the validity of the CertificateThe above configuration really does little checking at all - it simply checks that there is an x509 certificate on the card, and uses this to map to a username. In order of increasing paranoia, we can do some additional checking:
To perform certificate checking, you will need to copy the Issuer Certificates into the cacerts folder (as root) > cd /etc/X509/cacerts/ > cp ~/NHS-Root-CA.der . > cp ~/NHS-Level-1A.der . > chmod a+r * > make_hash_link.sh IssuesThe setup and configuration is not yet perfect. The 'hacked-together' appearance mentioned above is not slick. Additionally:
|