Debian Codegraph @

doc/poldi.texi

raw
1 \input texinfo @c -*- Texinfo -*-
2 @c Copyright (C) 2000, 2002, 2003, 2004, 2005,
3 @c 2007, 2008, 2009 Free Software Foundation, Inc.
4 @c
5 @c This file is part of Poldi.
6 @c
7 @c Permission is granted to copy, distribute and/or modify this document
8 @c under the terms of the GNU General Public License as published by the
9 @c Free Software Foundation; either version 2 of the License, or (at your
10 @c option) any later version. A copy of the license is included in the
11 @c file 'gpl.texi'.
12 @c
13 @setfilename poldi.info
14 @settitle The `Poldi Reference Manual
15
16 @dircategory GNU Utilities
17 @direntry
18 * poldi: (poldi). PAM authentication via OpenPGP smartcards.
19 @end direntry
20
21 @include version.texi
22
23 @ifinfo
24 This file documents `Poldi'.
25
26 This is Edition @value{EDITION}, last updated @value{UPDATED}, of
27 @cite{The Poldi Manual}, for Version @value{VERSION}.
28
29 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 g10 Code GmbH.
30
31 Permission is granted to copy, distribute and/or modify this document
32 under the terms of the GNU General Public License as published by the
33 Free Software Foundation; either version 2 of the License, or (at your
34 option) any later version. The text of the license can be found in the
35 section entitled ``Copying''.
36 @end ifinfo
37
38 @titlepage
39 @center @titlefont{The Poldi Manual}
40 @sp 6
41 @center Edition @value{EDITION}
42 @sp 1
43 @center last updated @value{UPDATED}
44 @sp 1
45 @center for version @value{VERSION}
46 @page
47 @vskip 0pt plus 1filll
48 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008 g10 Code GmbH.
49
50 Permission is granted to copy, distribute and/or modify this document
51 under the terms of the GNU General Public License as published by the
52 Free Software Foundation; either version 2 of the License, or (at your
53 option) any later version. The text of the license can be found in the
54 section entitled ``Copying''.
55 @end titlepage
56 @summarycontents
57 @contents
58 @page
59
60 @ifnottex
61 @node Top
62 @top Main Menu
63 This is Edition @value{EDITION}, last updated @value{UPDATED}, of
64 @cite{The Poldi Manual}, for Version
65 @value{VERSION} of Poldi.
66
67 Copyright @copyright{} 2004, 2005, 2006, 2007, 2008, 2009 g10 Code GmbH.
68
69 Permission is granted to copy, distribute and/or modify this document
70 under the terms of the GNU General Public License as published by the
71 Free Software Foundation; either version 2 of the License, or (at your
72 option) any later version. The text of the license can be found in the
73 section entitled ``Copying''.
74
75 @end ifnottex
76
77 @menu
78 * Overview::
79 * Authentication methods::
80 * Installation from Source::
81 * Configuration::
82 * Configuration Example::
83 * Testing::
84 * Notes on Applications::
85 * Copying:: The GNU General Public License
86
87 @c @detailmenu
88 @c --- The Detailed Node Listing ---
89 @c * Overview:: Overview
90 @c * Building:: Building Poldi
91 @c @end detailmenu
92
93 @end menu
94
95 @node Overview
96 @chapter Overview
97
98 Poldi is a PAM module implementing challenge/response based
99 authentication through the OpenPGP
100 smartcard@footnote{http://www.g10code.de/p-card.html}. It makes use of
101 several GnuPG components@footnote{Libgcrypt, Assuan, Scdaemon, Dirmngr}
102 and currently supports two authentication methods:
103
104 @table @asis
105 @item ``local-database'' authentication method
106
107 This method establishes the mapping between user accounts and
108 smartcards through a locally administered database.
109
110 @item ``X509'' authentication
111
112 This method uses the PKI infrastructure provided by Dirmngr for
113 validating certificates. OpenPGP smartcards are associated with X509
114 certificates through the smartcard's ``url'' field; the user account
115 name to use for authentication is extracted from the certificate.
116 @end table
117
118 This manual is primarily intended for system administrators interested
119 in setting up authentication through PAM Poldi.
120
121 @node Authentication methods
122 @chapter Authentication methods
123
124 This chapter explains the supported authentication methods in detail.
125
126 @menu
127 * Local-database authentication::
128 * X509 authentication::
129 @end menu
130
131 @node Local-database authentication
132 @section Local-database authentication
133
134 The login process through local database authentication consists
135 essentially of three parts: looking up the smartcards key on the local
136 computer, figuring out the desired identity for the login and finally
137 doing challenge/response authentication against the local key.
138
139 Poldi maintains a database, which associates local user accounts with
140 smartcards (through their serial number). One smartcard can be
141 associated with many users and one user can be associated with many
142 smartcards.
143
144 The public keys are stored in files in a subdirectory named
145 ``keys''. The files are named after the card serial numbers and must
146 contain the public key as a single S-Expression as it is printed out
147 by gpg-connect-agent (See below).
148
149 The mapping between keys and Unix accounts is to be established by
150 adding appropriate entries to the user database file named ``users''.
151 Such an entry is of the following form:
152
153 @example
154 <card serial number> <white space(s)> <account>.
155 @end example
156
157 @node X509 authentication
158 @section X509 authentication
159
160 With X509 authentication smartcards need to be associated with X509
161 certificates. This mapping is to be established through the ``url''
162 field on the OpenPGP smartcard. The url field is expected to hold
163 either a valid LDAP url (``ldap://...'') or a file url
164 (``file:///...''). After a certificate has been successfully looked
165 up, it is validated through Dirmngr and a challenge-response
166 authentication is triggered against the smartcard. The mapping
167 between smartcards and local accounts is established through the list
168 of email addresses contained in the certificate. Through the
169 configuration file, Poldi is informed about the ``X509 domain'' to
170 use. This domain is used when looking through the list of email
171 addresses for the local username on the system. Note: semantics might
172 change.
173
174 To illustrate this with an example: lets assume a user is trying to
175 authenticate himself through Poldi's X509 method. Poldi looks up the
176 url field of the user's smartcard and retrieves his X509 certificate.
177 The certificate contains two e-mail addresses: ``<dude@@example.com>''
178 and ``<fry@@gnupg.org>''. Since the administrator set the ``X509
179 domain'' to ``gnupg.org'' in Poldi's configuration file, Poldi will
180 pick out the address ``fry@@gnupg.org'' and (after successful
181 challenge-response authentication) will let the user login as ``fry''.
182
183 @node Installation from Source
184 @chapter Installation from Source
185
186 Building and installing Poldi from source should be pretty
187 straightforward, since it uses the GNU autotools. Build- and runtime
188 dependencies may vary with the enabled authentication methods.
189
190 Independent from enabled authentication methods, Poldi depends on
191 Libgpg-error, Libgcrypt, Libassuan, Scdaemon and of course Libpam.
192
193 The ``X509'' authentication method additionally has a build-time
194 dependency on libksba and requires Dirmngr to be properly setup at
195 runtime. The ``local database'' authentication method has no
196 additional requirements.
197
198 Details on the building procedure can be found in the file
199 ``INSTALL''.
200
201 At least one configure switch should be set:
202 @code{--with-pam-module-directory}, which specifies the installation
203 directory for PAM modules. Alternatively one can copy the built PAM
204 module (named ``pam_poldi.so'') to the correct place manually.
205
206 For building the Poldi package, ``make'' needs to be invoked.
207
208 Installing Poldi works by invoking the ``install'' make target. As
209 noted before, special care must be taken so that the PAM module ends up
210 in the correct place.
211
212 Poldi requires some directories beneath `SYSCONFDIR/poldi', which is
213 usually equal to `PREFIX/etc/poldi'. These directories can be created
214 manually or through the `install-conf-skeleton' make target.
215
216 @node Configuration
217 @chapter Configuration
218
219 Poldi can be configured through configuration files and through PAM
220 arguments. All configuration files of Poldi are stored beneath
221 ``@code{sysconfdir}/poldi''.
222
223 Poldi's main configuration file is
224 ``@code{sysconfdir}/poldi/poldi.conf''. The syntax of Poldi's
225 configuration file is identical to the one used by several other GnuPG
226 components; options and their values are written next to each other,
227 separated by a white space - one such configuration item per line.
228
229 Poldi supports the following authentication method independent
230 options, which can be specified in the main configuration file and in
231 the PAM configuration files as arguments to the Poldi PAM module (with
232 standard double-dash notation).
233
234 @table @code
235 @item log-file FILENAME
236 Specify the file to use for log messages.
237 @item auth-method AUTH-METHOD
238 Specify the authentication method to use. May be either ``localdb''
239 or ``x509''.
240 @item debug
241 Enable debugging messages.
242 @item scdaemon-program
243 Specify scdaemon executable to use.
244 @item scdaemon-options
245 Specify scdaemon configuration file to use.
246 @item modify-environment
247 This option causes Poldi to add certain Poldi related environment
248 variables to the PAM environment. Currently, the following variables
249 are set:
250 @table @asis
251 @item PAM_POLDI_AUTHENTICATED
252 This variable is set to the empty value.
253 @item PAM_POLDI_SERIALNO
254 This variable is set to the serial number of the card used during
255 authentication.
256 @item PAM_POLDI_LANG
257 This variable is set to the value of the LANG data field. Please note
258 that the exact semantics of this might change in the future.
259 @end table
260 @item quiet
261 This option causes Poldi to skip most of the
262 PAM info messages during authentication. Careful: the exact
263 semantics of this option might change. Primarily this is a
264 workaround for programs like GDM, which collect these info messages
265 and put them in a dialog box with an OK-button. When using e.g. GDM
266 with the quiet option, authentication should work without any
267 interaction.
268 @end table
269
270 Further configuration depends on the authentication method to use.
271
272 @menu
273 * Configuration for ``local-database'' authentication::
274 * Configuration for ``X509'' authentication::
275 @end menu
276
277 @node Configuration for ``local-database'' authentication
278 @section Configuration for ``local-database'' authentication
279
280 For the local-database authentication method additional configuration
281 is required. All local-database specific configuration files are
282 stored in the subdirectory ``localdb'':
283
284 @table @code
285 @item File: users
286 This file contains the mapping between smartcard serial numbers and
287 local usernames. Syntax: this file consists of entries - one entry
288 per line. Entries are of the form:
289 "<SERIALNO><WHITESPACES><USERNAME>\n" (without quotation marks and
290 without angle brackets. Allowed whitespaces are spaces and tabs.
291 <SERIALNO> is the serial number of an OpenPGP smartcard. It can be
292 obtained by "gpg --card-status" command as ``Application ID''.
293 <USERNAME> is a valid username on the system. Comments are opened
294 with "#" and terminated by a newline.
295
296 @item Directory: keys
297
298 This directory contains the "key database" for Poldis "local database"
299 authentication method. When Poldi needs the key belonging to a given
300 smartcard serial number, it looks up a file in this directory whose
301 name is exactly the serial number.
302
303 Usually only the system administrator is able to modify this directory
304 and thus establish the mapping between smartcards and keys. But it
305 might make sense for the administrator to make a file in this
306 directory writable for a ordinary user as well, since this would allow
307 that user to update his smartcard's key and adjust the mapping himself
308 without bothering the admin.
309 @end table
310
311
312 @node Configuration for ``X509'' authentication
313 @section Configuration for ``X509'' authentication
314
315 In case X509 authentication is enabled, Poldi tries to parse another
316 configuration file, namely ``poldi-x509.conf''. The following
317 configuration options are supported for this configuration file:
318
319 @table @code
320 @item dirmngr-socket FILENAME
321 Specify the socket to be used for communication with Dirmngr.
322
323 @item x509-domain STRING
324 Specify the X509 domain, which is simply a suffix required for
325 recognizing email addresses contained in user certificates as
326 belonging to the system on which authentication happens.
327 @end table
328
329 @node Configuration Example
330 @chapter Configuration Example
331
332 @menu
333 * Example for ``local-database'' authentication::
334 * Example for ``X509'' authentication::
335 @end menu
336
337 @node Example for ``local-database'' authentication
338 @section Example for ``local-database'' authentication
339
340 Lets assume a new installation of Poldi into the root filesystem,
341 having configuration files stored beneath /etc/poldi. The user
342 ``moritz'', who got an OpenPGP card with the serial number
343 ``D2760001240101010001000006550000, would like to authenticate himself
344 through Poldi.
345
346 First, the system administrator has to associate the user moritz with
347 the card's serial number:
348
349 @example
350 $ echo "D2760001240101010001000006550000 moritz" >> /etc/poldi/localdb/users
351 @end example
352
353 Second, the system administrator needs to write the card's key into a
354 card-specific key file. Therefore he inserts Moritz' smartcard and
355 executes:
356
357 @example
358 $ gpg-connect-agent "/datafile /etc/poldi/localdb/keys/D2760001240101010001000006550000" "SCD READKEY --advanced OPENPGP.3" /bye
359 @end example
360
361 The administrator wants to allow Moritz to update his card's key
362 himself; he/she types:
363
364 @example
365 $ chown moritz /etc/poldi/localdb/keys/D2760001240101010001000006550000
366 @end example
367
368 That's it.
369
370 @node Example for ``X509'' authentication
371 @section Example for ``X509'' authentication
372
373 Setting up X509 authentication is more complicated than setting up
374 localdb authentication, since more components are involved. This
375 sections tries to explain the basic steps.
376
377 When using localdb authentication, all we need is a list of keys on
378 the system, against which the challenge-response authentication is
379 done. For X509 authentication we need to:
380
381 @table @asis
382 @item ... create X509 certificates
383 one per smartcard, issued by a certificate authority trusted by Dirmngr
384 @item ... setup the smartcards
385 so that they ``point'' to ``their'' certificates
386 @item ... run Dirmngr
387 making it listen on a specific socket
388 @item ... setup Poldi
389 specifying Dirmngr's socket and the ``X509 domain'' in poldi-x509.conf.
390 @end table
391
392 Lets assume we don't have a certificate authority yet. For the CA
393 administration one needs a CA program, like OpenSSL. It can either be
394 used directly or through a GUI frontend like ``Tiny CA''.
395
396 FIXME: explain situation/goal (x509_domain).
397
398 Step 1: Create a CA. I created my test CA with the following
399 settings:
400
401 @table @asis
402 @item Common Name: Fnord Inc CA
403 @item Country Name: DE
404 @item Organization Name: Fnord Inc
405 @item Organizational Unit: Testing
406 @end table
407
408 The other options required are rather self-explanatory. After CA
409 creation, we need to generate a signing request. For this,
410 gpgsm --gen-key can be used (after inserting the users smartcard).
411 Here is an example session (* at the beginning means user's input):
412
413 @example
414 * $ gpgsm --gen-key
415 gpgsm (GnuPG) 2.1.10; Copyright (C) 2015 Free Software Foundation, Inc.
416 This is free software: you are free to change and redistribute it.
417 There is NO WARRANTY, to the extent permitted by law.
418
419 Please select what kind of key you want:
420 (1) RSA
421 (2) Existing key
422 (3) Existing key from card
423 * Your selection? 3
424 Serial number of the card: D276000124010200F517000000010000
425 Available keys:
426 (1) 101DE7B639FE29F4636BDEECF442A9273AFA6565 OPENPGP.1
427 (2) 65F67E742101C7FE6D5B33FCEFCF4F65EAF0688C OPENPGP.2
428 (3) 5D6C89682D07CCFC034AF508420BF2276D8018ED OPENPGP.3
429 * Your selection? 3
430 Possible actions for a RSA key:
431 (1) sign, encrypt
432 (2) sign
433 (3) encrypt
434 * Your selection? 2
435 * Enter the X.509 subject name: CN=Niibe Yutaka
436 Enter email addresses (end with an empty line):
437 * > gniibe@@fsij.org
438 * >
439 Enter DNS names (optional; end with an empty line):
440 * >
441 Enter URIs (optional; end with an empty line):
442 * >
443 * Create self-signed certificate? (y/N) y
444 These parameters are used:
445 Key-Type: card:OPENPGP.3
446 Key-Length: 1024
447 Key-Usage: sign
448 Serial: random
449 Name-DN: CN=Niibe Yutaka
450 Name-Email: gniibe@@fsij.org
451
452 * Proceed with creation? (y/N) y
453 Now creating self-signed certificate. This may take a while ...
454 gpgsm: about to sign the certificate for key: &5D6C89682D07CCFC034AF508420BF2276D8018ED
455 gpgsm: certificate created
456 Ready.
457 -----BEGIN CERTIFICATE-----
458 MIIDBDCCAeygAwIBAgIIElClyprjBd8wDQYJKoZIhvcNAQELBQAwFzEVMBMGA1UE
459 AxMMTmlpYmUgWXV0YWthMCAXDTE1MTIxNzEwNDI0NloYDzIwNjMwNDA1MTcwMDAw
460 WjAXMRUwEwYDVQQDEwxOaWliZSBZdXRha2EwggEiMA0GCSqGSIb3DQEBAQUAA4IB
461 DwAwggEKAoIBAQC/XqCK831odBl7Po174AExdRlOcyNSCKfJR18Mrxi8LnKwyjDg
462 GH7Z29Qm4XyZvnLkJvSLcYiSx46iDMWbIYH7w1Or57kp/sUzdlj6clmlV8zklVth
463 ppYWpFd+x6Qif9CndRKcPr9S1+tbAIlU5k42RG90XnhEQF1/V3MR01mG0Ey9xBAI
464 oHizZKX5XAjPheVGdDyZERB7Zry3e8kDrU+OjsVTjzq7oXtCE7EwI5c+pBQdF8qf
465 XZC35nAizu0oqQEBne5MsF9ZIBaY/D+hhXVV51oyyCEwNGTr8Ol6KXKK7MWhf16g
466 d0zjulwvO9xH88Q0n1eYur3plH+BZVjXOQPrAgMBAAGjUjBQMBoGA1UdEQQTMBGB
467 D2duaWliZUBmc2lqLm9yZzARBgorBgEEAdpHAgIBBAMBAf8wDwYDVR0TAQH/BAUw
468 AwEB/zAOBgNVHQ8BAf8EBAMCBsAwDQYJKoZIhvcNAQELBQADggEBAKNdnJ/q3eBt
469 h42lsahgqyeRvgs7PS+PeqJyOA+36MuHf8/1rdJpqIH/zX6s7S0c/HNqTUKMiB+S
470 XRQ9g5JAbldsvurYGCiSLM2bT4evC7odE8v0LOL2oBVuNZshy2jPOyI19598J2E2
471 RjrJSqRguYGIG2m9B5Edog3Fe7Cd7aN8Xp69QEylb2gJqYfP1qfpyzAWQi6oE9MH
472 NXh1TxDbiSOee8+5PZdgLaIsnuFG37+9c529oaJV6kTm4Qv4eSQF6XemytMgQVOM
473 kM1VFCBFd62fdVPHWqI4K9hdUImdKC4KZKT+HNfXo7W1BE6mDQJbutQkcxsFpBTB
474 w9T8Z/SIJJc=
475 -----END CERTIFICATE-----
476 $
477 @end example
478
479 Import the new certificate signing request in your CA and sign it,
480 yielding a new client certificate. A note on Tiny CA: the program
481 defaults FIXME mail address.
482
483 Export both, the CA certificate and the client certificate, in DER
484 format. Export a certificate revocation list (CRL) for your CA in DER
485 format.
486
487 Step 2: Setup OpenPGP smartcard
488
489 The OpenPGP smartcard is not a ``real'' PKCS#XYZ (FIXME?) smartcard -
490 it cannot store X509 certificates. So instead of ``uploading'' the
491 certificate to the smartcard, we write an URL to the card, through
492 which the complete certificate can be retrieved. Simply fill the
493 smartcard's ``url'' field with either a ``ldap://'' or a ``file://''
494 URL, pointing to the certificate. For LDAP urls to work, the
495 certificate must be stored on a LDAP server and Dirmngr must be
496 configured to use that LDAP server. For testing, one can simply
497 specify ``file:///some/where/cert-exported-from-ca.crt''. Editing the
498 card's data fields is to be done through GnuPG:
499
500 @example
501 $ gpg --card-edit # (or gpg2)
502 @end example
503
504 Step 3: Setup Dirmngr.
505
506 For debugging purposes it is usually a good idea to add:
507 @example
508 debug-all
509 log-file /some/where/dirmngr.log
510 @end example
511
512 to dirmngr.conf.
513
514 Drop the exported CA certificate in Dirmngr's ``trusted-certs''
515 directory.
516
517 Now, run Dirmngr:
518
519 @example
520 $ eval $(dirmngr --socket /some/where/dirmngr.S --daemon)
521 @end example
522
523 and inform it about the CRL:
524
525 @example
526 $ dirmngr-client --load-crl previously-saved-crl.der
527 @end example
528
529 Check Dirmngr's log file for any errors.
530
531 Step 4: Configure Poldi.
532
533 Obviously, in the main configuration file poldi.conf, we need:
534
535 @example
536 auth-method x509
537 @end example
538
539 Again, it's a very good idea to also add:
540
541 @example
542 debug
543 log-file /some/where/poldi.log
544 @end example
545
546 Add the following to ``poldi-x509.conf'':
547
548 @example
549 dirmngr-socket /some/where/dirmngr.S # the socket name previously specified
550 x509-domain example.com
551 @end example
552
553 Now, things should be ready for trying authentication.
554
555 @node Testing
556 @chapter Testing
557
558 Authentication through Poldi should be tested before activating the
559 module. For this purpose, the Poldi package includes a simple program
560 named ``pam-test'', which is suitable for testing PAM authentication.
561
562 @menu
563 * The pam-test program::
564 @end menu
565
566 @node The pam-test program
567 @section The pam-test program
568
569 pam-test is a small program suitable for testing PAM authentication,
570 without any Poldi specific aspects. Synopsis:
571
572 @example # FIXME
573 pam-test [options] <service name>
574 @end example
575
576 The program accepts the following options: FIXME.
577
578
579 @node Notes on Applications
580 @chapter Notes on Applications
581
582 Generally speaking, all applications containing a decent PAM
583 integration should work flawlessly in combination with Poldi. Sadly,
584 there are applications out there, which do not use PAM correctly.
585 Therefore, they might work not too well in case they are configured to
586 use Poldi.
587
588 This chapter attempts to list the most common problems or useful hints
589 in respect to popular applications.
590
591 When applications still ask for e.g. a username although Poldi is
592 activated for that application, it might be the case that other
593 authentication modules, which trigger this kind of user interaction, are
594 configured to run prior to Poldi.
595
596 @menu
597 * login::
598 * su::
599 * gdm::
600 * XScreensaver::
601 * xdm::
602 * kdm::
603 @end menu
604
605 @node login
606 @section login
607
608 The `login'-program contained in the `shadow'-package (>= v4.0.3) works
609 fine together with Poldi.
610
611 Usually login is launched by `getty', which might trigger user
612 interaction, which is not appropriate for use with Poldi (e.g., asking
613 for a username). In this case, getty needs to be told to skip the task
614 of username querying.
615
616 The getty-program from the `util-linux'-package can be started with the
617 `-n' argument in order to not ask for a username.
618
619 @node su
620 @section su
621
622 The `su'-program contained in the `shadow'-package (>= v4.0.3) works
623 fine together with Poldi.
624
625 @node gdm
626 @section gdm
627
628 GDM contains two frontends, the `graphical greeter' and the `standard
629 greeter'.
630
631 At least the standard greeter can be used with Poldi just fine; the
632 graphical greeter obviously asks for usernames prior to triggering PAM
633 authentication.
634
635 @node XScreensaver
636 @section XScreensaver
637
638 XScreensaver (at least Version >= 5.07, possibly earlier versions too)
639 works quite well with Poldi authentication. By combining SCDaemons
640 ~/.gnupg/scd-event mechanism with the xscreensaver-command program, one
641 can easily setup an environment in which the card-removal event triggers
642 screen locking and the card-insertion event triggers screen unlocking.
643
644 Note that this also applies to GNOME Screensaver; one only needs to use
645 the gnome-screensaver-command program instead of xscreensaver-command.
646
647 @node xdm
648 @section xdm
649
650 XDM does ask for usernames prior to triggering PAM authentication, as
651 such it is not too suitable for use with Poldi.
652
653 @node kdm
654 @section kdm
655
656 KDM asks for username and password in it's default configuration,
657 instead of implementing PAM correctly.
658
659 @include gpl.texi
660
661 @bye