• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

m4/H11-Sep-2019-11,50510,518

po/H03-May-2022-1,036888

src/H03-May-2022-2,5401,993

.gitignoreH A D16-Apr-20191.1 KiB107102

ABOUT-NLSH A D16-May-201891.6 KiB1,2831,244

COPYINGH A D20-Mar-201825.8 KiB505418

Makefile.amH A D24-Apr-2019741 2720

Makefile.inH A D11-Sep-201928.8 KiB926823

NEWSH A D11-Sep-20191.5 KiB4032

README.mdH A D11-Sep-20196.3 KiB10365

aclocal.m4H A D11-Sep-201952.5 KiB1,4721,333

bootstrapH A D20-Mar-2018203 118

compileH A D25-Jan-20177.2 KiB348258

config.guessH A D12-Nov-201642.9 KiB1,4631,270

config.h.inH A D11-Sep-20195 KiB178124

config.rpathH A D16-May-201818.3 KiB691594

config.subH A D12-Nov-201635.5 KiB1,8261,688

configureH A D11-Sep-2019540.7 KiB18,32515,373

configure.acH A D11-Sep-20193.7 KiB169139

depcompH A D25-Jan-201723 KiB792502

install-shH A D25-Jan-201714.8 KiB509329

ltmain.shH A D20-Aug-2016316.8 KiB11,1577,986

missingH A D25-Jan-20176.7 KiB216143

README.md

1# Welcome to pam_p11
2
3Pam_p11 is a plugable authentication module (pam) package for using crpytographic tokens such as smart cards and usb crypto tokens for authentication.
4
5Pam_p11 uses [libp11](https://github.com/OpenSC/libp11/) to access any PKCS#11 module. It should be compatible with any implementation, but it is primarely developed using [OpenSC](https://github.com/OpenSC/OpenSC/).
6
7Pam_p11 implements two authentication methods:
8
9- verify a token using a known public key found in OpenSSH's `~/.ssh/authorized_keys`.
10- verify a token using a known certificate found in `~/.eid/authorized_certificates`.
11
12Pam_p11 is very simple, it has no config file, does not know about certificate chains, certificate authorities, revocation lists or OCSP. Perfect for the small installation with no frills.
13
14Pam_p11 was written by an international team and is licensed as Open Source software under the LGPL license.
15
16[![Build Status](https://travis-ci.org/OpenSC/pam_p11.svg?branch=master)](https://travis-ci.org/OpenSC/pam_p11) [![Coverity Scan Status](https://scan.coverity.com/projects/15452/badge.svg)](https://scan.coverity.com/projects/opensc-pam_p11)
17
18## Installing pam_p11
19
20Installation is quite easy:
21
22```
23wget https://github.com/OpenSC/pam_p11/releases/download/pam_p11-0.1.6/pam_p11-0.1.6.tar.gz
24tar xfvz pam_p11-0.1.6.tar.gz
25cd pam_p11-0.1.6
26./configure --prefix=/usr --libdir=/lib/
27make
28make install
29```
30
31Pam_p11 depends on pkg-config, openssl, libp11 and pam.  If you don't have pkg-config installed, please do so and try again.  If pkg-config is not found, please change your PATH environment setting.  If openssl is not installed, please do so. If openssl is not found, please change your PKG_CONFIG_PATH environment setting to include the directory with "openssl.pc" or "libp11.pc" file. Some linux distributions split openssl into a runtime package and a development package, you need to install both. Same might be true for pam and libp11.
32
33## Using pam_p11
34
35### Login
36
37To use pam_p11 with some application like `sudo`, edit `/etc/pam.d/sudo` and add something like the following at the beginning of the file:
38
39```
40auth  sufficient  /usr/local/lib/security/pam_p11.so  /usr/local/lib/opensc-pkcs11.so
41```
42
43Replace `/usr/local/lib/opensc-pkcs11.so` with your PKCS#11 implementation. Using an absolute path to `pam_p11.so` avoids the need to write to a system directory, which is especially useful for macOS with system integrity protection (SIP) enabled.
44
45An optional second argument to `pam_p11.so` may be used to check for a specific format when prompting for the token's password. On macOS this defaults to the regular expression `^[[:digit:]]*$` to avoid confusion with the user's password in the login screen. pam_p11 uses [POSIX-Extended Regular Expressions](https://man.openbsd.org/re_format.7) for matching.
46
47While testing it is best to keep a door open. Editing the configuration files from a different machine via SSH helps reverting a bad PAM login configuration. Replace `sufficient` with `required` and remove other unwanted PAM modules from the file only when you've successfully verified the configuration.
48
49To enable pam_p11 for all logins (graphical and terminal based), change the following configuration files as described above:
50
51| Operating System | PAM configuration file     |
52| ---------------- | -------------------------- |
53| macOS            | `/etc/pam.d/authorization` |
54| Debian           | `/etc/pam.d/common-auth`   |
55| Arch Linux       | `/etc/pam.d/system-auth`   |
56
57### PIN change and unblock
58
59To allow changing and unblocking the PIN via pam_p11, add the following to your configuration:
60
61```
62password  optional    /usr/local/lib/security/pam_p11.so  /usr/local/lib/opensc-pkcs11.so
63```
64
65An optional second argument to `pam_p11.so` may be used to check for a specific format when prompting for the token's password. On macOS this defaults to the regular expression `^[[:digit:]]*$` to avoid confusion with the user's password in the login screen. pam_p11 uses [POSIX-Extended Regular Expressions](https://man.openbsd.org/re_format.7) for matching.
66
67### User configuration via `~/.eid/authorized_certificates`
68
69A user may create a `~/.eid/` directory and create a file `~/.eid/authorized_certificates` with authorized certificates. You can do that via
70
71```
72mkdir -p ~/.eid
73chmod 0755 ~/.eid
74pkcs11-tool --read-object --type cert --id 45 --module /usr/lib/opensc-pkcs11.so --output-file cert.cer
75openssl x509 -inform DER -in cert.cer -outform PEM >> ~/.eid/authorized_certificates
76chmod 0644 ~/.eid/authorized_certificates
77```
78
79This example uses the `pkcs11-tool` command from opensc to read a certificate (id `45`) from the smart card. Use `pkcs11-tool --list-objects --type cert --module /usr/lib/opensc-pkcs11.so` to view all certificates available on the card.
80
81It is very important that only the user of the file can write to it. You can have any number of certificates in that file. The certificates need to be in PEM format. DER format is not supported.
82
83### User configuration via `~/.ssh/authorized_keys`
84
85A user may create a `~/.ssh/` directory and create a file `~/.ssh/authorized_keys` with authorized public keys. You can do that via
86
87```
88mkdir -p ~/.ssh
89chmod 0755 ~/.ssh
90ssh-keygen -D /usr/lib/opensc-pkcs11.so >> ~/.ssh/authorized_keys
91chmod 0644 ~/.ssh/authorized_keys
92```
93
94This example uses the `ssh-keygen` command from openssh to read the default user public key (id 45) from the smart card in reader 0.  Note that this tool prints the public keys in two formats: ssh v1 and ssh v2 format. It is recommended to edit the file and delete one of those two lines. Also you might want to add a comment / identifier at the end of the line.
95
96It is very important that only the user of the file can write to it.  You can have any number of public keys in that file.
97
98Note it is currently not possible to convert existing ssh keys into pem format and store them on a smart card. (To be precise: OpenSC has no such functionality, not sure about other implementations.)
99
100## Security Note
101
102pam_p11 simply compares public keys and request the cryptographic token to sign some random data and verifiy the signature with the public key. No CA chain checking is done, no CRL is looked at, and they don't know what OCSP is. This works fine for small installations, but if you want any of those features, please have a look at [Pam_pkcs11](https://github.com/OpenSC/pam_pkcs11) for a fully fledged PAM module for smart card authentication.
103