409. Fingerprints, FIDO keys and smart cards
Three kinds of hardware can stand in for, or add to, a password on KDOS: a fingerprint reader, a FIDO2 or U2F security key, and a smart card in a reader. This page covers what each needs, the files that set it up, and the procedures that use it: enrolling a finger for sudo and the lock screen, making an SSH key that lives on a security key, and reaching a smart card’s certificates. What each one does not reach is listed under Known gaps.
Installation
All of these are in the base the ISO carries, live and installed, except the smart-card driver ccid and opensc, which sudo kdos update install <port> adds (see Installing software):
| Hardware | Ports | Started by |
|---|---|---|
| Fingerprint reader | libfprint (the reader drivers), fprintd (the daemon, pam_fprintd.so and the fprintd-* tools) |
The system bus, on the first call to net.reactivated.Fprint. It runs /usr/libexec/fprintd as root through dbus-daemon-launch-helper; there is no service script |
| FIDO2 / U2F key | libfido2 (the library and the fido2-token, fido2-cred and fido2-assert tools); openssh, built --with-security-key-builtin |
Nothing: the key is a USB HID device, opened by the program that uses it |
| Smart card | pcsc-lite (pcscd), ccid (the driver for USB CCID readers), opensc (opensc-pkcs11.so and the pkcs11-tool and opensc-tool tools), p11-kit |
/etc/init.d/47_pcscd.sh, at boot, after 41_polkitd |
pam provides the PAM stacks. Two of them ask for a finger: sudo‘s, and the lock screen’s kde-fingerprint from kscreenlocker. The greeter’s and the consoles’ logins ask for the password alone, and SSH does not use PAM: openssh is built without --with-pam.
pcscd is enabled on both the live medium and an installed system; service list shows it as pcscd. A fingerprint enrolled on the live medium is kept in the overlay’s upper layer, so it is gone at power-off unless a persistence store exists; see The live medium and persistence.
Configuration
/etc/pam.d/sudo
Written by the sudo port’s build.sh. The first line tries an enrolled finger, and the leading - skips the line when pam_fprintd.so is missing:
# Begin /etc/pam.d/sudo
# an enrolled finger, when there is a reader and one is on file; the leading
# dash skips the line on an image without fprintd rather than failing it
-auth sufficient pam_fprintd.so
# include the default auth settings
auth include system-auth
# include the default account settings
account include system-account
# Set default environment variables for the service user
session required pam_env.so
# include system session defaults
session include system-session
# End /etc/pam.d/sudo
ports/core/auth/sudo/build.sh, lines 36–54
system-auth, which it includes, is written by the pam port’s build.sh:
# Begin /etc/pam.d/system-auth
account required pam_unix.so
auth required pam_unix.so nullok
auth optional pam_permit.so
session required pam_limits.so
session required pam_unix.so
password required pam_unix.so sha512 shadow try_first_pass
# End /etc/pam.d/system-auth
ports/core/auth/pam/build.sh, lines 36–43
/etc/fprintd.conf
Installed by fprintd as upstream ships it. It holds one setting, type=file under [storage], so enrolled prints are files under /var/lib/fprint, one directory per account. The directory does not exist until the first finger is enrolled.
/etc/udev/rules.d/70-kdos-fido.rules
Gives every FIDO2 and U2F key to the dialout group. From fs/etc/udev/rules.d/:
# KDOS — FIDO2/U2F security keys, for libfido2: `ssh-keygen -t ed25519-sk`,
# an ssh login with an -sk key, and the fido2-* tools.
#
# Matched on ID_SECURITY_TOKEN rather than a vendor table. eudev's
# 60-fido-id.rules runs fido_id on every hidraw node, and fido_id sets the
# variable when the HID report descriptor declares the FIDO usage page — so a
# key from a vendor nobody listed is covered the day it is plugged in.
#
# libfido2's own 70-u2f.rules is not installed. It grants a `plugdev` group
# this system does not have, which eudev resolves to gid 0, and it sorts after
# this file, so it would take the grant back.
#
# dialout, like every other device a person plugs in to drive: the key asks
# for a touch before it signs anything, and the group is the line between the
# console user and the other accounts on the machine.
SUBSYSTEM=="hidraw", ENV{ID_SECURITY_TOKEN}=="1", GROUP="dialout", MODE="0660"
fs/etc/udev/rules.d/70-kdos-fido.rules
The live medium’s kdos account is in dialout, and so is the account the installer makes from it. Any other account needs it for a key: sudo usermod -aG dialout <user>, then log in again. The other device rules are in The device groups and the udev rules.
/etc/init.d/47_pcscd.sh
From fs/etc/init.d/. It runs pcscd in the foreground under the supervisor, after reading /etc/default/pcscd:
case "$1" in
start)
if [ ! -x "$DAEMON" ]; then
echo "[SKIP] $NAME: $DAEMON not found"
exit 0
fi
echo "[KDOS] Starting $NAME..."
read_defaults
# After polkitd: every client is authorised through polkit, and a
# daemon up before it refuses them all. --foreground for supervision;
# readers come and go through udev hotplug, so it runs for ever.
install -d -m 755 /run/pcscd
supervise "$NAME" "$DAEMON" --foreground "${ARGS[@]}"
;;
stop)
stop_service "$NAME"
;;
status)
check_status "$NAME"
;;
*)
echo "Usage: $0 {start|stop|status}"
exit 1
;;
esac
fs/etc/init.d/47_pcscd.sh, lines 56–80
read_defaults, above that block in the script, parses the file and does not source it. It exports PCSCLITE_FILTER_IGNORE_READER_NAMES, PCSCLITE_FILTER_EXTEND_READER_NAMES and PCSCLITE_HP_DROPDIR to the daemon, and splits PCSCD_ARGS into extra arguments after --foreground. A line that is not KEY=value, or names any other key, is reported in /run/kdos-init.pcscd.log (or on the terminal, for service start) and skipped.
/etc/default/pcscd
From fs/etc/default/. The file and its keys are pcsc-lite’s own, the ones pcscd(8) documents, and every key ships commented out, so out of the box pcscd sees every reader under its own name:
# The smart card daemon's settings. 47_pcscd.sh reads this at every start, so
# `sudo service restart pcscd` applies an edit. Every key is optional.
#
# One KEY=value per line. The file is PARSED, NEVER SOURCED: a value is taken
# as written, one pair of surrounding quotes removed, and the only expansion is
# $HOSTNAME, to this machine's host name. A key not listed here is reported
# in /run/kdos-init.pcscd.log and skipped.
# Extra arguments for pcscd, split at spaces and added after --foreground:
# --debug or --error for the log level, --reader-name-no-serial and
# --reader-name-no-interface for shorter reader names; pcscd(8) has the rest.
#PCSCD_ARGS="--debug"
# Readers to ignore: pcscd skips every reader whose name contains one of these
# words, ':' between them. "Contactless" hides the contactless half of a dual
# reader; `opensc-tool --list-readers` prints the names.
#PCSCLITE_FILTER_IGNORE_READER_NAMES="Contactless"
# Text added to the end of every reader's name, so a reader redirected to
# another machine (a remote desktop's smart card redirection) says whose it is.
#PCSCLITE_FILTER_EXTEND_READER_NAMES=" $HOSTNAME"
# Where pcscd looks for USB reader drivers, in place of /usr/lib/pcsc/drivers.
#PCSCLITE_HP_DROPDIR="/usr/lib/pcsc/drivers"
pcsc-lite is built -Dfilter_names=true, which is what makes pcscd read the two filter variables. A value is taken as written, without its quotes; $HOSTNAME is the one expansion.
/etc/polkit-1/rules.d/50-kdos.rules
pcscd asks polkit about every client and every reader. KDOS’s rule file leaves both actions to pcsc-lite’s own defaults, which are allow_active: the person in the active session at the machine reaches every reader with no password, and an SSH login or a session switched away from reaches none. The comment at the head of the rule file says so, from fs/etc/polkit-1/rules.d/50-kdos.rules:
* A NAME NOT IN THIS FILE IS THE DEFAULT'S. Removable drives, Wi-Fi and the
* network toggles, hotspots, smart cards, modems, suspend and power-off,
* brightness, power profiles, the time zone and network time, the accent and
* the rest are allow_active upstream already, and the person at the machine
* gets them with no rule here. testing/fixtures/polkit holds the measured
* defaults and the table of answers this file must produce, and
* testing/selftest.sh evaluates this file against both.
fs/etc/polkit-1/rules.d/50-kdos.rules, lines 37–43
The whole rule file is explained in What 50-kdos.rules changes.
Other files
| File | Provided by | Holds |
|---|---|---|
/usr/lib/udev/rules.d/92_pcscd_ccid.rules |
ccid’s build.sh |
Gives CCID readers to the pcscd group, which pcsc-lite’s postinstall.sh creates |
/etc/reader.conf.d/ |
pcsc-lite’s build.sh makes it; ccid installs libccidtwin in it, every line commented out |
Serial readers, which udev cannot find. libccidtwin is the template for a Gemalto serial reader: uncomment its DEVICENAME, FRIENDLYNAME and LIBPATH lines and name the port |
Usage
Enrolling a finger for sudo
Not verified on real hardware: no reader has been through these steps on this system.
Check that the reader is seen. With the reader plugged in:
sudo fprintd-list "$USER"It prints
found 1 devicesand the device’s path, then the account’s enrolled fingers, orNo devices availablewhen libfprint drives no reader on the machine. Every otherfprintd-*command answers the same way without a reader;fprintd-enrollprintsImpossible to enroll: GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available.Enrol, from System Settings → Users → Configure Fingerprint Authentication, or from Konsole in the session. fprintd’s polkit action lets the person in the active session at the machine enrol after typing their own password once:
fprintd-enrollTouch the reader each time it asks, until it prints
Enroll result: enroll-completed. Without-fit enrolsright-index-finger;-f left-thumb, or any other name the command lists when given a wrong one, enrols that finger instead.Check it:
fprintd-verifyUse it: the next
sudowaits for a finger on the reader before it asks for the password, and the lock screen accepts a finger beside the password. A failed or skipped finger falls through to the password.
To remove every print of an account, run sudo fprintd-delete "$USER".
An SSH key on a security key
Plug in the key, and check that it is seen:
fido2-token -LIt prints one line per key, and nothing, with exit status 0, when it finds none. Nothing printed with the key plugged in means the account cannot open it; see Troubleshooting.
Make a key pair whose private half stays on the security key:
ssh-keygen -t ed25519-skTouch the key when
ssh-keygenasks. Add-O residentto store the key on the token, so it can be loaded on another machine withssh-keygen -K.Copy the public half to the server, as for any key:
ssh-copy-id -i ~/.ssh/id_ed25519_sk.pub user@server.Log in with
ssh user@server, and touch the key when asked.
The same key type works for logging in to this machine; see Logging in with a key.
Reaching a smart card
Not verified on real hardware: no card has been used in a reader on this system.
Check that the service runs and sees the reader:
service status pcscd opensc-tool --list-readersCheck that the card is seen:
pkcs11-tool --list-slots pkcs11-tool --list-objectsWith no reader attached,
opensc-toolprintsNo smart card readers found.andpkcs11-toolprintsNo slots.. A login that is not the active session at the machine, such as an SSH login or a session switched away from, is refused bypcscdand gets the same two answers; the refusal is only in the service’s log (see Troubleshooting).Use it. For SSH, name the PKCS#11 module:
ssh -I /usr/lib/opensc-pkcs11.so user@serverGnuTLS programs and openconnect find the card through p11-kit, which loads
opensc-pkcs11.sofrom its module file; see Thunderbolt, phones, smart cards and firmware updates.
Hiding or renaming a reader
A dual-interface reader shows up as two readers, one for contact cards and one for contactless ones, and a program that takes the first reader it finds may take the wrong one. pcscd can drop readers by name, and can add text to every reader’s name.
List the readers’ names:
opensc-tool --list-readersEdit
/etc/default/pcscd:sudoedit /etc/default/pcscdUncomment
PCSCLITE_FILTER_IGNORE_READER_NAMESand set it to a word from the name of each reader to hide, with:between words; a reader is hidden when its name contains any of them. UncommentPCSCLITE_FILTER_EXTEND_READER_NAMESto add its value to every name, such as" $HOSTNAME", which tells a reader redirected into a remote desktop apart from the remote machine’s own.Restart the service, which reads the file only when it starts:
sudo service restart pcscdCheck:
opensc-tool --list-readersleaves out a hidden reader, andpcscdlogsReader name "<name>" contains "<word>": ignoredin/run/kdos-svc.pcscd.logeach time it skips one.
Tips
kdos doctorchecksdbus-daemon-launch-helper’s setuid bit and itsmessagebusgroup. Without them the system bus cannot start fprintd, and no fingerprint command works.- A FIDO key asks for a touch before it signs, so
dialoutmembership alone does not let another process use it silently. ssh-keygen -t ecdsa-skmakes an ECDSA key instead, for a token that does not support Ed25519.- The pcscd service’s log is
/run/kdos-svc.pcscd.log.PCSCD_ARGS="--debug"in/etc/default/pcscd, thensudo service restart pcscd, makes it log at its debug level, which includes every reader it finds and the driver it loads for it.
Troubleshooting
sudo fprintd-list prints Failed to get Fprintd manager or Impossible to get devices. The system bus could not start the daemon. Run kdos doctor and read the dbus-daemon-launch-helper line in the Desktop section; then check that /usr/share/dbus-1/system-services/net.reactivated.Fprint.service exists.
fprintd-enroll prints failed to claim device. fprintd’s polkit actions allow the active session at the machine; from SSH or a session switched away from, run it as sudo fprintd-enroll <user>.
sudo over SSH waits before asking for the password. For an account with a finger enrolled, pam_fprintd waits on the machine’s reader first; see A fingerprint unlocks sudo and the lock screen, and nothing else. Wait for it to time out, or remove the account’s prints with sudo fprintd-delete <user> if it never uses the reader locally.
fido2-token -L prints nothing, or ssh-keygen -t ed25519-sk ends Key enrollment failed: device not found. Check the account’s groups with id: it needs dialout. Check the node: ls -l /dev/hidraw* should show one owned by group dialout, mode crw-rw----. If the node is root root, mode crw-------, the rule did not match: udevadm info /dev/hidrawN | grep ID_SECURITY_TOKEN prints nothing for a device whose HID descriptor does not declare FIDO. Every other HID device, such as a virtual machine’s tablet, has such a node.
pkcs11-tool --list-slots reports no slots, or access is denied. Run service status pcscd; start it with sudo service start pcscd. Check that the command runs in the active session at the machine, since polkit refuses an SSH login and a session switched away from: pkcheck --action-id org.debian.pcsc-lite.access_pcsc --process $$ answers Not authorized. from either, and /run/kdos-svc.pcscd.log shows Process <pid> (user: <uid>) is NOT authorized for action: access_pcsc and Rejected unauthorized PC/SC client for every attempt. Check that pcscd sees the reader: opensc-tool --list-readers.
Known gaps
- A fingerprint unlocks sudo and the lock screen, and nothing else
- Smart cards, drawing tablets and software radios have not met hardware
- No port provides a PAM module for FIDO keys, so a security key cannot log in to the console or unlock
sudo.
See also
- The device groups and the udev rules: why
dialout, and why upstream’splugdevrules are left out - polkit and the authentication agent: why fprintd’s actions need
sudo - Thunderbolt, phones, smart cards and firmware updates
- sudo, PAM and polkit, udev and device groups, SSH server, Screen lock, Live persistence