xref: /minix3/crypto/external/bsd/heimdal/dist/doc/setup.texi (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1ebfedea0SLionel Sambuc@c Id
2*0a6a1f1dSLionel Sambuc@c $NetBSD: setup.texi,v 1.1.1.3 2014/04/24 12:45:27 pettai Exp $
3ebfedea0SLionel Sambuc
4ebfedea0SLionel Sambuc@node Setting up a realm, Applications, Building and Installing, Top
5ebfedea0SLionel Sambuc
6ebfedea0SLionel Sambuc@chapter Setting up a realm
7ebfedea0SLionel Sambuc
8ebfedea0SLionel SambucA
9ebfedea0SLionel Sambuc@cindex realm
10ebfedea0SLionel Sambucrealm is an administrative domain.  The name of a Kerberos realm is
11ebfedea0SLionel Sambucusually the Internet domain name in uppercase.  Call your realm the same
12ebfedea0SLionel Sambucas your Internet domain name if you do not have strong reasons for not
13ebfedea0SLionel Sambucdoing so.  It will make life easier for you and everyone else.
14ebfedea0SLionel Sambuc
15ebfedea0SLionel Sambuc@menu
16ebfedea0SLionel Sambuc* Configuration file::
17ebfedea0SLionel Sambuc* Creating the database::
18ebfedea0SLionel Sambuc* Modifying the database::
19ebfedea0SLionel Sambuc* Checking the setup::
20ebfedea0SLionel Sambuc* keytabs::
21ebfedea0SLionel Sambuc* Remote administration::
22ebfedea0SLionel Sambuc* Password changing::
23ebfedea0SLionel Sambuc* Testing clients and servers::
24ebfedea0SLionel Sambuc* Slave Servers::
25ebfedea0SLionel Sambuc* Incremental propagation::
26ebfedea0SLionel Sambuc* Encryption types and salting::
27ebfedea0SLionel Sambuc* Credential cache server - KCM::
28ebfedea0SLionel Sambuc* Cross realm::
29ebfedea0SLionel Sambuc* Transit policy::
30ebfedea0SLionel Sambuc* Setting up DNS::
31ebfedea0SLionel Sambuc* Using LDAP to store the database::
32ebfedea0SLionel Sambuc* Providing Kerberos credentials to servers and programs::
33ebfedea0SLionel Sambuc* Setting up PK-INIT::
34ebfedea0SLionel Sambuc* Debugging Kerberos problems::
35ebfedea0SLionel Sambuc@end menu
36ebfedea0SLionel Sambuc
37ebfedea0SLionel Sambuc@node  Configuration file, Creating the database, Setting up a realm, Setting up a realm
38ebfedea0SLionel Sambuc@section Configuration file
39ebfedea0SLionel Sambuc
40ebfedea0SLionel SambucTo setup a realm you will first have to create a configuration file:
41ebfedea0SLionel Sambuc@file{/etc/krb5.conf}. The @file{krb5.conf} file can contain many
42ebfedea0SLionel Sambucconfiguration options, some of which are described here.
43ebfedea0SLionel Sambuc
44ebfedea0SLionel SambucThere is a sample @file{krb5.conf} supplied with the distribution.
45ebfedea0SLionel Sambuc
46ebfedea0SLionel SambucThe configuration file is a hierarchical structure consisting of
47ebfedea0SLionel Sambucsections, each containing a list of bindings (either variable
48ebfedea0SLionel Sambucassignments or subsections). A section starts with
49ebfedea0SLionel Sambuc@samp{[@samp{section-name}]}.  A binding consists of a left hand side, an equal sign
50ebfedea0SLionel Sambuc(@samp{=}) and a right hand side (the left hand side tag must be
51ebfedea0SLionel Sambucseparated from the equal sign with some whitespace). Subsections have a
52ebfedea0SLionel Sambuc@samp{@{} as the first non-whitespace character after the equal sign. All
53ebfedea0SLionel Sambucother bindings are treated as variable assignments. The value of a
54ebfedea0SLionel Sambucvariable extends to the end of the line.
55ebfedea0SLionel Sambuc
56ebfedea0SLionel Sambuc@example
57ebfedea0SLionel Sambuc[section1]
58ebfedea0SLionel Sambuc        a-subsection = @{
59ebfedea0SLionel Sambuc                var = value1
60ebfedea0SLionel Sambuc                other-var = value with @{@}
61ebfedea0SLionel Sambuc                sub-sub-section = @{
62ebfedea0SLionel Sambuc                        var = 123
63ebfedea0SLionel Sambuc                @}
64ebfedea0SLionel Sambuc        @}
65ebfedea0SLionel Sambuc        var = some other value
66ebfedea0SLionel Sambuc[section2]
67ebfedea0SLionel Sambuc        var = yet another value
68ebfedea0SLionel Sambuc@end example
69ebfedea0SLionel Sambuc
70ebfedea0SLionel SambucIn this manual, names of sections and bindings will be given as strings
71ebfedea0SLionel Sambucseparated by slashes (@samp{/}). The @samp{other-var} variable will thus
72ebfedea0SLionel Sambucbe @samp{section1/a-subsection/other-var}.
73ebfedea0SLionel Sambuc
74ebfedea0SLionel SambucFor in-depth information about the contents of the configuration file, refer to
75ebfedea0SLionel Sambucthe @file{krb5.conf} manual page. Some of the more important sections
76ebfedea0SLionel Sambucare briefly described here.
77ebfedea0SLionel Sambuc
78ebfedea0SLionel SambucThe @samp{libdefaults} section contains a list of library configuration
79ebfedea0SLionel Sambucparameters, such as the default realm and the timeout for KDC
80ebfedea0SLionel Sambucresponses. The @samp{realms} section contains information about specific
81ebfedea0SLionel Sambucrealms, such as where they hide their KDC@. This section serves the same
82ebfedea0SLionel Sambucpurpose as the Kerberos 4 @file{krb.conf} file, but can contain more
83ebfedea0SLionel Sambucinformation. Finally the @samp{domain_realm} section contains a list of
84ebfedea0SLionel Sambucmappings from domains to realms, equivalent to the Kerberos 4
85ebfedea0SLionel Sambuc@file{krb.realms} file.
86ebfedea0SLionel Sambuc
87ebfedea0SLionel SambucTo continue with the realm setup, you will have to create a configuration file,
88ebfedea0SLionel Sambucwith contents similar to the following.
89ebfedea0SLionel Sambuc
90ebfedea0SLionel Sambuc@example
91ebfedea0SLionel Sambuc[libdefaults]
92ebfedea0SLionel Sambuc        default_realm = MY.REALM
93ebfedea0SLionel Sambuc[realms]
94ebfedea0SLionel Sambuc        MY.REALM = @{
95ebfedea0SLionel Sambuc                kdc = my.kdc my.slave.kdc
96ebfedea0SLionel Sambuc                kdc = my.third.kdc
97ebfedea0SLionel Sambuc                kdc = 130.237.237.17
98ebfedea0SLionel Sambuc                kdc = [2001:6b0:1:ea::100]:88
99ebfedea0SLionel Sambuc        @}
100ebfedea0SLionel Sambuc[domain_realm]
101ebfedea0SLionel Sambuc        .my.domain = MY.REALM
102ebfedea0SLionel Sambuc
103ebfedea0SLionel Sambuc@end example
104ebfedea0SLionel Sambuc
105ebfedea0SLionel SambucIf you use a realm name equal to your domain name, you can omit the
106ebfedea0SLionel Sambuc@samp{libdefaults}, and @samp{domain_realm}, sections. If you have a DNS
107ebfedea0SLionel SambucSRV-record for your realm, or your Kerberos server has DNS CNAME
108ebfedea0SLionel Sambuc@samp{kerberos.my.realm}, you can omit the @samp{realms} section too.
109ebfedea0SLionel Sambuc
110*0a6a1f1dSLionel Sambuc@cindex KRB5_CONFIG
111*0a6a1f1dSLionel SambucIf you want to use a different configuration file then the default you
112*0a6a1f1dSLionel Sambuccan point a file with the enviroment variable @samp{KRB5_CONFIG}.
113*0a6a1f1dSLionel Sambuc
114*0a6a1f1dSLionel Sambuc@example
115*0a6a1f1dSLionel Sambucenv KRB5_CONFIG=$HOME/etc/krb5.conf kinit user@@REALM
116*0a6a1f1dSLionel Sambuc@end example
117*0a6a1f1dSLionel Sambuc
118ebfedea0SLionel Sambuc@node Creating the database, Modifying the database, Configuration file, Setting up a realm
119ebfedea0SLionel Sambuc@section Creating the database
120ebfedea0SLionel Sambuc
121ebfedea0SLionel SambucThe database library will look for the database in the directory
122ebfedea0SLionel Sambuc@file{@value{dbdir}}, so you should probably create that directory.
123ebfedea0SLionel SambucMake sure the directory has restrictive permissions.
124ebfedea0SLionel Sambuc
125ebfedea0SLionel Sambuc@example
126ebfedea0SLionel Sambuc# mkdir /var/heimdal
127ebfedea0SLionel Sambuc@end example
128ebfedea0SLionel Sambuc
129ebfedea0SLionel SambucThe keys of all the principals are stored in the database.  If you
130ebfedea0SLionel Sambucchoose to, these can be encrypted with a master key.  You do not have to
131ebfedea0SLionel Sambucremember this key (or password), but just to enter it once and it will
132ebfedea0SLionel Sambucbe stored in a file (@file{/var/heimdal/m-key}).  If you want to have a
133ebfedea0SLionel Sambucmaster key, run @samp{kstash} to create this master key:
134ebfedea0SLionel Sambuc
135ebfedea0SLionel Sambuc@example
136ebfedea0SLionel Sambuc# kstash
137ebfedea0SLionel SambucMaster key:
138ebfedea0SLionel SambucVerifying password - Master key:
139ebfedea0SLionel Sambuc@end example
140ebfedea0SLionel Sambuc
141ebfedea0SLionel SambucIf you want to generate a random master key you can use the
142ebfedea0SLionel Sambuc@kbd{--random-key} flag to kstash. This will make sure you have a good key
143ebfedea0SLionel Sambucon which attackers can't do a dictionary attack.
144ebfedea0SLionel Sambuc
145ebfedea0SLionel SambucIf you have a master key, make sure you make a backup of your master
146ebfedea0SLionel Sambuckey file; without it backups of the database are of no use.
147ebfedea0SLionel Sambuc
148ebfedea0SLionel SambucTo initialise the database use the @command{kadmin} program, with the
149ebfedea0SLionel Sambuc@kbd{-l} option (to enable local database mode). First issue a
150ebfedea0SLionel Sambuc@kbd{init MY.REALM} command. This will create the database and insert
151ebfedea0SLionel Sambucdefault principals for that realm. You can have more than one realm in
152ebfedea0SLionel Sambucone database, so @samp{init} does not destroy any old database.
153ebfedea0SLionel Sambuc
154ebfedea0SLionel SambucBefore creating the database, @samp{init} will ask you some questions
155ebfedea0SLionel Sambucabout maximum ticket lifetimes.
156ebfedea0SLionel Sambuc
157ebfedea0SLionel SambucAfter creating the database you should probably add yourself to it. You
158ebfedea0SLionel Sambucdo this with the @samp{add} command. It takes as argument the name of a
159ebfedea0SLionel Sambucprincipal. The principal should contain a realm, so if you haven't set up
160ebfedea0SLionel Sambuca default realm, you will need to explicitly include the realm.
161ebfedea0SLionel Sambuc
162ebfedea0SLionel Sambuc@example
163ebfedea0SLionel Sambuc# kadmin -l
164ebfedea0SLionel Sambuckadmin> init MY.REALM
165ebfedea0SLionel SambucRealm max ticket life [unlimited]:
166ebfedea0SLionel SambucRealm max renewable ticket life [unlimited]:
167ebfedea0SLionel Sambuckadmin> add me
168ebfedea0SLionel SambucMax ticket life [unlimited]:
169ebfedea0SLionel SambucMax renewable life [unlimited]:
170ebfedea0SLionel SambucAttributes []:
171ebfedea0SLionel SambucPassword:
172ebfedea0SLionel SambucVerifying password - Password:
173ebfedea0SLionel Sambuc@end example
174ebfedea0SLionel Sambuc
175ebfedea0SLionel SambucNow start the KDC and try getting a ticket.
176ebfedea0SLionel Sambuc
177ebfedea0SLionel Sambuc@example
178ebfedea0SLionel Sambuc# kdc &
179ebfedea0SLionel Sambuc# kinit me
180ebfedea0SLionel Sambucme@@MY.REALMS's Password:
181ebfedea0SLionel Sambuc# klist
182ebfedea0SLionel SambucCredentials cache: /tmp/krb5cc_0
183ebfedea0SLionel Sambuc        Principal: me@@MY.REALM
184ebfedea0SLionel Sambuc
185ebfedea0SLionel Sambuc  Issued           Expires          Principal
186ebfedea0SLionel SambucAug 25 07:25:55  Aug 25 17:25:55  krbtgt/MY.REALM@@MY.REALM
187ebfedea0SLionel Sambuc@end example
188ebfedea0SLionel Sambuc
189ebfedea0SLionel SambucIf you are curious you can use the @samp{dump} command to list all the
190ebfedea0SLionel Sambucentries in the database.  It should look something similar to the
191ebfedea0SLionel Sambucfollowing example (note that the entries here are truncated for
192ebfedea0SLionel Sambuctypographical reasons):
193ebfedea0SLionel Sambuc
194ebfedea0SLionel Sambuc@smallexample
195ebfedea0SLionel Sambuckadmin> dump
196ebfedea0SLionel Sambucme@@MY.REALM 1:0:1:0b01d3cb7c293b57:-:0:7:8aec316b9d1629e3baf8 ...
197ebfedea0SLionel Sambuckadmin/admin@@MY.REALM 1:0:1:e5c8a2675b37a443:-:0:7:cb913ebf85 ...
198ebfedea0SLionel Sambuckrbtgt/MY.REALM@@MY.REALM 1:0:1:52b53b61c875ce16:-:0:7:c8943be ...
199ebfedea0SLionel Sambuckadmin/changepw@@MY.REALM 1:0:1:f48c8af2b340e9fb:-:0:7:e3e6088 ...
200ebfedea0SLionel Sambuc@end smallexample
201ebfedea0SLionel Sambuc
202ebfedea0SLionel Sambuc@node Modifying the database, Checking the setup, Creating the database, Setting up a realm
203ebfedea0SLionel Sambuc@section Modifying the database
204ebfedea0SLionel Sambuc
205ebfedea0SLionel SambucAll modifications of principals are done with with kadmin.
206ebfedea0SLionel Sambuc
207ebfedea0SLionel SambucA principal has several attributes and lifetimes associated with it.
208ebfedea0SLionel Sambuc
209ebfedea0SLionel SambucPrincipals are added, renamed, modified, and deleted with the kadmin
210ebfedea0SLionel Sambuccommands @samp{add}, @samp{rename}, @samp{modify}, @samp{delete}.
211ebfedea0SLionel SambucBoth interactive editing and command line flags can be used (use --help
212ebfedea0SLionel Sambucto list the available options).
213ebfedea0SLionel Sambuc
214ebfedea0SLionel SambucThere are different kinds of types for the fields in the database;
215ebfedea0SLionel Sambucattributes, absolute time times and relative times.
216ebfedea0SLionel Sambuc
217ebfedea0SLionel Sambuc@subsection Attributes
218ebfedea0SLionel Sambuc
219ebfedea0SLionel SambucWhen doing interactive editing, attributes are listed with @samp{?}.
220ebfedea0SLionel Sambuc
221ebfedea0SLionel SambucThe attributes are given in a comma (@samp{,}) separated list.
222ebfedea0SLionel SambucAttributes are removed from the list by prefixing them with @samp{-}.
223ebfedea0SLionel Sambuc
224ebfedea0SLionel Sambuc@smallexample
225ebfedea0SLionel Sambuckadmin> modify me
226ebfedea0SLionel SambucMax ticket life [1 day]:
227ebfedea0SLionel SambucMax renewable life [1 week]:
228ebfedea0SLionel SambucPrincipal expiration time [never]:
229ebfedea0SLionel SambucPassword expiration time [never]:
230ebfedea0SLionel SambucAttributes [disallow-renewable]: requires-pre-auth,-disallow-renewable
231ebfedea0SLionel Sambuckadmin> get me
232ebfedea0SLionel Sambuc            Principal: me@@MY.REALM
233ebfedea0SLionel Sambuc[...]
234ebfedea0SLionel Sambuc           Attributes: requires-pre-auth
235ebfedea0SLionel Sambuc@end smallexample
236ebfedea0SLionel Sambuc
237ebfedea0SLionel Sambuc@subsection Absolute times
238ebfedea0SLionel Sambuc
239ebfedea0SLionel SambucThe format for absolute times are any of the following:
240ebfedea0SLionel Sambuc
241ebfedea0SLionel Sambuc@smallexample
242ebfedea0SLionel Sambucnever
243ebfedea0SLionel Sambucnow
244ebfedea0SLionel SambucYYYY-mm-dd
245ebfedea0SLionel SambucYYYY-mm-dd HH:MM:SS
246ebfedea0SLionel Sambuc@end smallexample
247ebfedea0SLionel Sambuc
248ebfedea0SLionel Sambuc
249ebfedea0SLionel Sambuc@subsection Relative times
250ebfedea0SLionel Sambuc
251ebfedea0SLionel SambucThe format for relative times are any of the following combined:
252ebfedea0SLionel Sambuc
253ebfedea0SLionel Sambuc@smallexample
254ebfedea0SLionel SambucN year
255ebfedea0SLionel SambucM month
256ebfedea0SLionel SambucO day
257ebfedea0SLionel SambucP hour
258ebfedea0SLionel SambucQ minute
259ebfedea0SLionel SambucR second
260ebfedea0SLionel Sambuc@end smallexample
261ebfedea0SLionel Sambuc
262ebfedea0SLionel Sambuc@c Describe more of kadmin commands here...
263ebfedea0SLionel Sambuc
264ebfedea0SLionel Sambuc@node Checking the setup, keytabs, Modifying the database, Setting up a realm
265ebfedea0SLionel Sambuc@section Checking the setup
266ebfedea0SLionel Sambuc
267ebfedea0SLionel SambucThere are two tools that can check the consistency of the Kerberos
268ebfedea0SLionel Sambucconfiguration file and the Kerberos database.
269ebfedea0SLionel Sambuc
270ebfedea0SLionel SambucThe Kerberos configuration file is checked using
271ebfedea0SLionel Sambuc@command{verify_krb5_conf}. The tool checks for common errors, but
272ebfedea0SLionel Sambuccommonly there are several uncommon configuration entries that are
273ebfedea0SLionel Sambucnever added to the tool and thus generates ``unknown entry'' warnings.
274ebfedea0SLionel SambucThis is usually nothing to worry about.
275ebfedea0SLionel Sambuc
276ebfedea0SLionel SambucThe database check is built into the kadmin tool. It will check for
277ebfedea0SLionel Sambuccommon configuration error that will cause problems later. Common
278ebfedea0SLionel Sambuccheck are for existence and flags on important principals. The
279ebfedea0SLionel Sambucdatabase check by run by the following command :
280ebfedea0SLionel Sambuc
281ebfedea0SLionel Sambuc@example
282ebfedea0SLionel Sambuckadmin -l check REALM.EXAMPLE.ORG
283ebfedea0SLionel Sambuc@end example
284ebfedea0SLionel Sambuc
285*0a6a1f1dSLionel Sambuc@node keytabs, Remote administration, Checking the setup, Setting up a realm
286ebfedea0SLionel Sambuc@section keytabs
287ebfedea0SLionel Sambuc
288ebfedea0SLionel SambucTo extract a service ticket from the database and put it in a keytab, you
289ebfedea0SLionel Sambucneed to first create the principal in the database with @samp{add}
290ebfedea0SLionel Sambuc(using the @kbd{--random-key} flag to get a random key) and then
291ebfedea0SLionel Sambucextract it with @samp{ext_keytab}.
292ebfedea0SLionel Sambuc
293ebfedea0SLionel Sambuc@example
294ebfedea0SLionel Sambuckadmin> add --random-key host/my.host.name
295ebfedea0SLionel SambucMax ticket life [unlimited]:
296ebfedea0SLionel SambucMax renewable life [unlimited]:
297ebfedea0SLionel SambucAttributes []:
298ebfedea0SLionel Sambuckadmin> ext host/my.host.name
299ebfedea0SLionel Sambuckadmin> exit
300ebfedea0SLionel Sambuc# ktutil list
301ebfedea0SLionel SambucVersion  Type             Principal
302ebfedea0SLionel Sambuc     1   des-cbc-md5      host/my.host.name@@MY.REALM
303ebfedea0SLionel Sambuc     1   des-cbc-md4      host/my.host.name@@MY.REALM
304ebfedea0SLionel Sambuc     1   des-cbc-crc      host/my.host.name@@MY.REALM
305ebfedea0SLionel Sambuc     1   des3-cbc-sha1    host/my.host.name@@MY.REALM
306ebfedea0SLionel Sambuc@end example
307ebfedea0SLionel Sambuc
308*0a6a1f1dSLionel Sambuc@node Remote administration, Password changing, keytabs, Setting up a realm
309ebfedea0SLionel Sambuc@section Remote administration
310ebfedea0SLionel Sambuc
311ebfedea0SLionel SambucThe administration server, @command{kadmind}, can be started by
312ebfedea0SLionel Sambuc@command{inetd} (which isn't recommended) or run as a normal daemon. If you
313ebfedea0SLionel Sambucwant to start it from @command{inetd} you should add a line similar to the
314ebfedea0SLionel Sambucone below to your @file{/etc/inetd.conf}.
315ebfedea0SLionel Sambuc
316ebfedea0SLionel Sambuc@example
317ebfedea0SLionel Sambuckerberos-adm stream     tcp     nowait  root /usr/heimdal/libexec/kadmind kadmind
318ebfedea0SLionel Sambuc@end example
319ebfedea0SLionel Sambuc
320ebfedea0SLionel SambucYou might need to add @samp{kerberos-adm} to your @file{/etc/services}
321ebfedea0SLionel Sambucas @samp{749/tcp}.
322ebfedea0SLionel Sambuc
323ebfedea0SLionel SambucAccess to the administration server is controlled by an ACL file,
324ebfedea0SLionel Sambuc(default @file{/var/heimdal/kadmind.acl}.) The file has the following
325ebfedea0SLionel Sambucsyntax:
326ebfedea0SLionel Sambuc@smallexample
327ebfedea0SLionel Sambucprincipal       [priv1,priv2,...]       [glob-pattern]
328ebfedea0SLionel Sambuc@end smallexample
329ebfedea0SLionel Sambuc
330ebfedea0SLionel SambucThe matching is from top to bottom for matching principals (and if given,
331ebfedea0SLionel Sambucglob-pattern).  When there is a match, the access rights of that line are
332ebfedea0SLionel Sambucapplied.
333ebfedea0SLionel Sambuc
334ebfedea0SLionel SambucThe privileges you can assign to a principal are: @samp{add},
335ebfedea0SLionel Sambuc@samp{change-password} (or @samp{cpw} for short), @samp{delete},
336ebfedea0SLionel Sambuc@samp{get}, @samp{list}, and @samp{modify}, or the special privilege
337ebfedea0SLionel Sambuc@samp{all}. All of these roughly correspond to the different commands
338ebfedea0SLionel Sambucin @command{kadmin}.
339ebfedea0SLionel Sambuc
340ebfedea0SLionel SambucIf a @var{glob-pattern} is given on a line, it restricts the access
341ebfedea0SLionel Sambucrights for the principal to only apply for subjects that match the
342ebfedea0SLionel Sambucpattern.  The patterns are of the same type as those used in shell
343ebfedea0SLionel Sambucglobbing, see @url{none,,fnmatch(3)}.
344ebfedea0SLionel Sambuc
345ebfedea0SLionel SambucIn the example below @samp{lha/admin} can change every principal in the
346ebfedea0SLionel Sambucdatabase. @samp{jimmy/admin} can only modify principals that belong to
347ebfedea0SLionel Sambucthe realm @samp{E.KTH.SE}. @samp{mille/admin} is working at the
348ebfedea0SLionel Sambuchelp desk, so he should only be able to change the passwords for single
349ebfedea0SLionel Sambuccomponent principals (ordinary users). He will not be able to change any
350ebfedea0SLionel Sambuc@samp{/admin} principal.
351ebfedea0SLionel Sambuc
352ebfedea0SLionel Sambuc@example
353ebfedea0SLionel Sambuclha/admin@@E.KTH.SE	all
354ebfedea0SLionel Sambucjimmy/admin@@E.KTH.SE	all		*@@E.KTH.SE
355ebfedea0SLionel Sambucjimmy/admin@@E.KTH.SE	all		*/*@@E.KTH.SE
356ebfedea0SLionel Sambucmille/admin@@E.KTH.SE	change-password	*@@E.KTH.SE
357ebfedea0SLionel Sambuc@end example
358ebfedea0SLionel Sambuc
359ebfedea0SLionel Sambuc@node Password changing, Testing clients and servers, Remote administration, Setting up a realm
360ebfedea0SLionel Sambuc@section Password changing
361ebfedea0SLionel Sambuc
362ebfedea0SLionel SambucTo allow users to change their passwords, you should run @command{kpasswdd}.
363ebfedea0SLionel SambucIt is not run from @command{inetd}.
364ebfedea0SLionel Sambuc
365ebfedea0SLionel SambucYou might need to add @samp{kpasswd} to your @file{/etc/services} as
366ebfedea0SLionel Sambuc@samp{464/udp}.  If your realm is not setup to use DNS, you might also
367ebfedea0SLionel Sambucneed to add a @samp{kpasswd_server} entry to the realm configuration
368ebfedea0SLionel Sambucin @file{/etc/krb5.conf} on client machines:
369ebfedea0SLionel Sambuc
370ebfedea0SLionel Sambuc@example
371ebfedea0SLionel Sambuc[realms]
372ebfedea0SLionel Sambuc        MY.REALM = @{
373ebfedea0SLionel Sambuc                kdc = my.kdc my.slave.kdc
374ebfedea0SLionel Sambuc                kpasswd_server = my.kdc
375ebfedea0SLionel Sambuc        @}
376ebfedea0SLionel Sambuc@end example
377ebfedea0SLionel Sambuc
378ebfedea0SLionel Sambuc@subsection Password quality assurance
379ebfedea0SLionel Sambuc
380ebfedea0SLionel SambucIt is important that users have good passwords, both to make it harder
381ebfedea0SLionel Sambucto guess them and to avoid off-line attacks (although
382ebfedea0SLionel Sambucpre-authentication provides some defence against off-line attacks).
383ebfedea0SLionel SambucTo ensure that the users choose good passwords, you can enable
384ebfedea0SLionel Sambucpassword quality controls in @command{kpasswdd} and @command{kadmind}.
385ebfedea0SLionel SambucThe controls themselves are done in a shared library or an external
386ebfedea0SLionel Sambucprogram that is used by @command{kpasswdd}.  To configure in these
387ebfedea0SLionel Sambuccontrols, add lines similar to the following to your
388ebfedea0SLionel Sambuc@file{/etc/krb5.conf}:
389ebfedea0SLionel Sambuc
390ebfedea0SLionel Sambuc@example
391ebfedea0SLionel Sambuc[password_quality]
392ebfedea0SLionel Sambuc	policies = external-check builtin:minimum-length modulename:policyname
393ebfedea0SLionel Sambuc	external_program = /bin/false
394ebfedea0SLionel Sambuc	policy_libraries = @var{library1.so} @var{library2.so}
395ebfedea0SLionel Sambuc@end example
396ebfedea0SLionel Sambuc
397ebfedea0SLionel SambucIn @samp{[password_quality]policies} the module name is optional if
398ebfedea0SLionel Sambucthe policy name is unique in all modules (members of
399ebfedea0SLionel Sambuc@samp{policy_libraries}).  All built-in policies can be qualified with
400ebfedea0SLionel Sambuca module name of @samp{builtin} to unambiguously specify the built-in
401ebfedea0SLionel Sambucpolicy and not a policy by the same name from a loaded module.
402ebfedea0SLionel Sambuc
403ebfedea0SLionel SambucThe built-in policies are
404ebfedea0SLionel Sambuc
405ebfedea0SLionel Sambuc@itemize @bullet
406ebfedea0SLionel Sambuc
407ebfedea0SLionel Sambuc@item external-check
408ebfedea0SLionel Sambuc
409ebfedea0SLionel SambucExecutes the program specified by @samp{[password_quality]external_program}.
410ebfedea0SLionel Sambuc
411ebfedea0SLionel SambucA number of key/value pairs are passed as input to the program, one per
412ebfedea0SLionel Sambucline, ending with the string @samp{end}.  The key/value lines are of
413ebfedea0SLionel Sambucthe form
414ebfedea0SLionel Sambuc@example
415ebfedea0SLionel Sambucprincipal: @var{principal}
416ebfedea0SLionel Sambucnew-password: @var{password}
417ebfedea0SLionel Sambuc@end example
418ebfedea0SLionel Sambucwhere @var{password} is the password to check for the previous
419ebfedea0SLionel Sambuc@var{principal}.
420ebfedea0SLionel Sambuc
421ebfedea0SLionel SambucIf the external application approves the password, it should return
422ebfedea0SLionel Sambuc@samp{APPROVED} on standard out and exit with exit code 0.  If it
423ebfedea0SLionel Sambucdoesn't approve the password, an one line error message explaining the
424ebfedea0SLionel Sambucproblem should be returned on standard error and the application
425ebfedea0SLionel Sambucshould exit with exit code 0.  In case of a fatal error, the
426ebfedea0SLionel Sambucapplication should, if possible, print an error message on standard
427ebfedea0SLionel Sambucerror and exit with a non-zero error code.
428ebfedea0SLionel Sambuc
429ebfedea0SLionel Sambuc@item minimum-length
430ebfedea0SLionel Sambuc
431ebfedea0SLionel SambucThe minimum length password quality check reads the configuration file
432ebfedea0SLionel Sambucstanza @samp{[password_quality]min_length} and requires the password
433ebfedea0SLionel Sambucto be at least this length.
434ebfedea0SLionel Sambuc
435ebfedea0SLionel Sambuc@item character-class
436ebfedea0SLionel Sambuc
437ebfedea0SLionel SambucThe character-class password quality check reads the configuration
438ebfedea0SLionel Sambucfile stanza @samp{[password_quality]min_classes}. The policy requires
439ebfedea0SLionel Sambucthe password to have characters from at least that many character
440ebfedea0SLionel Sambucclasses. Default value if not given is 3.
441ebfedea0SLionel Sambuc
442ebfedea0SLionel SambucThe four different characters classes are, uppercase, lowercase,
443ebfedea0SLionel Sambucnumber, special characters.
444ebfedea0SLionel Sambuc
445ebfedea0SLionel Sambuc@end itemize
446ebfedea0SLionel Sambuc
447ebfedea0SLionel SambucIf you want to write your own shared object to check password
448ebfedea0SLionel Sambucpolicies, see the manual page @manpage{kadm5_pwcheck,3}.
449ebfedea0SLionel Sambuc
450ebfedea0SLionel SambucCode for a password quality checking function that uses the cracklib
451ebfedea0SLionel Sambuclibrary can be found in @file{lib/kadm5/sample_password_check.c} in
452ebfedea0SLionel Sambucthe source code distribution.  It requires that the cracklib library
453ebfedea0SLionel Sambucbe built with the patch available at
454ebfedea0SLionel Sambuc@url{ftp://ftp.pdc.kth.se/pub/krb/src/cracklib.patch}.
455ebfedea0SLionel Sambuc
456ebfedea0SLionel SambucA sample policy external program is included in
457ebfedea0SLionel Sambuc@file{lib/kadm5/check-cracklib.pl}.
458ebfedea0SLionel Sambuc
459ebfedea0SLionel SambucIf no password quality checking function is configured, the only check
460ebfedea0SLionel Sambucperformed is that the password is at least six characters long.
461ebfedea0SLionel Sambuc
462ebfedea0SLionel SambucTo check the password policy settings, use the command
463ebfedea0SLionel Sambuc@command{verify-password-quality} in @command{kadmin} program. The password
464ebfedea0SLionel Sambucverification is only performed locally, on the client.  It may be
465ebfedea0SLionel Sambucconvenient to set the environment variable @samp{KRB5_CONFIG} to point
466ebfedea0SLionel Sambucto a test version of @file{krb5.conf} while you're testing the
467ebfedea0SLionel Sambuc@samp{[password_quality]} stanza that way.
468ebfedea0SLionel Sambuc
469ebfedea0SLionel Sambuc@node Testing clients and servers, Slave Servers, Password changing, Setting up a realm
470ebfedea0SLionel Sambuc@section Testing clients and servers
471ebfedea0SLionel Sambuc
472ebfedea0SLionel SambucNow you should be able to run all the clients and servers.  Refer to the
473ebfedea0SLionel Sambucappropriate man pages for information on how to use them.
474ebfedea0SLionel Sambuc
475ebfedea0SLionel Sambuc@node Slave Servers, Incremental propagation, Testing clients and servers, Setting up a realm
476ebfedea0SLionel Sambuc@section Slave servers, Incremental propagation, Testing clients and servers, Setting up a realm
477ebfedea0SLionel Sambuc
478ebfedea0SLionel SambucIt is desirable to have at least one backup (slave) server in case the
479ebfedea0SLionel Sambucmaster server fails. It is possible to have any number of such slave
480ebfedea0SLionel Sambucservers but more than three usually doesn't buy much more redundancy.
481ebfedea0SLionel Sambuc
482ebfedea0SLionel SambucAll Kerberos servers for a realm must have the same database so that
483ebfedea0SLionel Sambucthey present the same service to the users.  The
484ebfedea0SLionel Sambuc@pindex hprop
485ebfedea0SLionel Sambuc@command{hprop} program, running on the master, will propagate the database
486ebfedea0SLionel Sambucto the slaves, running
487ebfedea0SLionel Sambuc@pindex hpropd
488ebfedea0SLionel Sambuc@command{hpropd} processes.
489ebfedea0SLionel Sambuc
490ebfedea0SLionel SambucEvery slave needs a database directory, the master key (if it was used
491ebfedea0SLionel Sambucfor the database) and a keytab with the principal
492ebfedea0SLionel Sambuc@samp{hprop/@var{hostname}}.  Add the principal with the
493ebfedea0SLionel Sambuc@pindex ktutil
494ebfedea0SLionel Sambuc@command{ktutil} command and start
495ebfedea0SLionel Sambuc@pindex hpropd
496ebfedea0SLionel Sambuc@command{hpropd}, as follows:
497ebfedea0SLionel Sambuc
498ebfedea0SLionel Sambuc@example
499ebfedea0SLionel Sambucslave# ktutil get -p foo/admin hprop/`hostname`
500ebfedea0SLionel Sambucslave# mkdir /var/heimdal
501ebfedea0SLionel Sambucslave# hpropd
502ebfedea0SLionel Sambuc@end example
503ebfedea0SLionel Sambuc
504ebfedea0SLionel SambucThe master will use the principal @samp{kadmin/hprop} to authenticate to
505ebfedea0SLionel Sambucthe slaves.  This principal should be added when running @kbd{kadmin -l
506ebfedea0SLionel Sambucinit} but if you do not have it in your database for whatever reason,
507ebfedea0SLionel Sambucplease add it with @kbd{kadmin -l add}.
508ebfedea0SLionel Sambuc
509ebfedea0SLionel SambucThen run
510ebfedea0SLionel Sambuc@pindex hprop
511ebfedea0SLionel Sambuc@code{hprop} on the master:
512ebfedea0SLionel Sambuc
513ebfedea0SLionel Sambuc@example
514ebfedea0SLionel Sambucmaster# hprop slave
515ebfedea0SLionel Sambuc@end example
516ebfedea0SLionel Sambuc
517ebfedea0SLionel SambucThis was just an hands-on example to make sure that everything was
518ebfedea0SLionel Sambucworking properly.  Doing it manually is of course the wrong way, and to
519ebfedea0SLionel Sambucautomate this you will want to start
520ebfedea0SLionel Sambuc@pindex hpropd
521ebfedea0SLionel Sambuc@command{hpropd} from @command{inetd} on the slave(s) and regularly run
522ebfedea0SLionel Sambuc@pindex hprop
523ebfedea0SLionel Sambuc@command{hprop} on the master to regularly propagate the database.
524ebfedea0SLionel SambucStarting the propagation once an hour from @command{cron} is probably a
525ebfedea0SLionel Sambucgood idea.
526ebfedea0SLionel Sambuc
527ebfedea0SLionel Sambuc@node Incremental propagation, Encryption types and salting, Slave Servers, Setting up a realm
528ebfedea0SLionel Sambuc@section Incremental propagation
529ebfedea0SLionel Sambuc
530ebfedea0SLionel SambucThere is also a newer mechanism for
531ebfedea0SLionel Sambucdoing incremental propagation in Heimdal.  Instead of sending the whole
532ebfedea0SLionel Sambucdatabase regularly, it sends the changes as they happen on the master to
533ebfedea0SLionel Sambucthe slaves.  The master keeps track of all the changes by assigning a
534ebfedea0SLionel Sambucversion number to every change to the database.  The slaves know which
535ebfedea0SLionel Sambucwas the latest version they saw and in this way it can be determined if
536ebfedea0SLionel Sambucthey are in sync or not.  A log of all the changes is kept on the master,
537ebfedea0SLionel Sambucand when a slave is at an older version than the oldest one in the
538ebfedea0SLionel Sambuclog, the whole database has to be sent.
539ebfedea0SLionel Sambuc
540ebfedea0SLionel SambucProtocol-wise, all the slaves connect to the master and as a greeting
541ebfedea0SLionel Sambuctell it the latest version that they have (@samp{IHAVE} message).  The
542ebfedea0SLionel Sambucmaster then responds by sending all the changes between that version and
543ebfedea0SLionel Sambucthe current version at the master (a series of @samp{FORYOU} messages)
544ebfedea0SLionel Sambucor the whole database in a @samp{TELLYOUEVERYTHING} message.  There is
545ebfedea0SLionel Sambucalso a keep-alive protocol that makes sure all slaves are up and running.
546ebfedea0SLionel Sambuc
547ebfedea0SLionel SambucIn addition on listening on the network to get connection from new
548ebfedea0SLionel Sambucslaves, the ipropd-master also listens on a status unix
549ebfedea0SLionel Sambucsocket. kadmind and kpasswdd both open that socket when a transation
550ebfedea0SLionel Sambucis done and written a notification to the socket. That cause
551ebfedea0SLionel Sambucipropd-master to check for new version in the log file. As a fallback in
552ebfedea0SLionel Sambuccase a notification is lost by the unix socket, the log file is
553ebfedea0SLionel Sambucchecked after 30 seconds of no event.
554ebfedea0SLionel Sambuc
555ebfedea0SLionel Sambuc@subsection Configuring incremental propagation
556ebfedea0SLionel Sambuc
557ebfedea0SLionel SambucThe program that runs on the master is @command{ipropd-master} and all
558ebfedea0SLionel Sambucclients run @command{ipropd-slave}.
559ebfedea0SLionel Sambuc
560ebfedea0SLionel SambucCreate the file @file{/var/heimdal/slaves} on the master containing all
561ebfedea0SLionel Sambucthe slaves that the database should be propagated to.  Each line contains
562ebfedea0SLionel Sambucthe full name of the principal (for example
563ebfedea0SLionel Sambuc@samp{iprop/hemligare.foo.se@@FOO.SE}).
564ebfedea0SLionel Sambuc
565ebfedea0SLionel SambucYou should already have @samp{iprop/tcp} defined as 2121, in your
566ebfedea0SLionel Sambuc@file{/etc/services}.  Otherwise, or if you need to use a different port
567ebfedea0SLionel Sambucfor some peculiar reason, you can use the @kbd{--port} option.  This is
568ebfedea0SLionel Sambucuseful when you have multiple realms to distribute from one server.
569ebfedea0SLionel Sambuc
570ebfedea0SLionel SambucThen you need to create those principals that you added in the
571ebfedea0SLionel Sambucconfiguration file.  Create one @samp{iprop/hostname} for the master and
572ebfedea0SLionel Sambucfor every slave.
573ebfedea0SLionel Sambuc
574ebfedea0SLionel Sambuc
575ebfedea0SLionel Sambuc@example
576ebfedea0SLionel Sambucmaster# /usr/heimdal/sbin/ktutil get iprop/`hostname`
577ebfedea0SLionel Sambuc@end example
578ebfedea0SLionel Sambuc
579ebfedea0SLionel Sambuc@example
580ebfedea0SLionel Sambucslave# /usr/heimdal/sbin/ktutil get iprop/`hostname`
581ebfedea0SLionel Sambuc@end example
582ebfedea0SLionel Sambuc
583ebfedea0SLionel Sambuc
584ebfedea0SLionel SambucThe next step is to start the @command{ipropd-master} process on the master
585ebfedea0SLionel Sambucserver.  The @command{ipropd-master} listens on the UNIX domain socket
586ebfedea0SLionel Sambuc@file{/var/heimdal/signal} to know when changes have been made to the
587ebfedea0SLionel Sambucdatabase so they can be propagated to the slaves.  There is also a
588ebfedea0SLionel Sambucsafety feature of testing the version number regularly (every 30
589ebfedea0SLionel Sambucseconds) to see if it has been modified by some means that do not raise
590ebfedea0SLionel Sambucthis signal.  Then, start @command{ipropd-slave} on all the slaves:
591ebfedea0SLionel Sambuc
592ebfedea0SLionel Sambuc@example
593ebfedea0SLionel Sambucmaster# /usr/heimdal/libexec/ipropd-master &
594ebfedea0SLionel Sambucslave#  /usr/heimdal/libexec/ipropd-slave master &
595ebfedea0SLionel Sambuc@end example
596ebfedea0SLionel Sambuc
597ebfedea0SLionel SambucTo manage the iprop log file you should use the @command{iprop-log}
598ebfedea0SLionel Sambuccommand. With it you can dump, truncate and replay the logfile.
599ebfedea0SLionel Sambuc
600ebfedea0SLionel Sambuc@node Encryption types and salting, Credential cache server - KCM, Incremental propagation, Setting up a realm
601ebfedea0SLionel Sambuc@section Encryption types and salting
602ebfedea0SLionel Sambuc@cindex Salting
603ebfedea0SLionel Sambuc@cindex Encryption types
604ebfedea0SLionel Sambuc
605ebfedea0SLionel SambucThe encryption types that the KDC is going to assign by default is
606ebfedea0SLionel Sambucpossible to change. Since the keys used for user authentication is
607ebfedea0SLionel Sambucsalted the encryption types are described together with the salt
608ebfedea0SLionel Sambucstrings.
609ebfedea0SLionel Sambuc
610ebfedea0SLionel SambucSalting is used to make it harder to pre-calculate all possible
611ebfedea0SLionel Sambuckeys. Using a salt increases the search space to make it almost
612ebfedea0SLionel Sambucimpossible to pre-calculate all keys. Salting is the process of mixing a
613ebfedea0SLionel Sambucpublic string (the salt) with the password, then sending it through an
614ebfedea0SLionel Sambucencryption type specific string-to-key function that will output the
615ebfedea0SLionel Sambucfixed size encryption key.
616ebfedea0SLionel Sambuc
617ebfedea0SLionel SambucIn Kerberos 5 the salt is determined by the encryption type, except in
618ebfedea0SLionel Sambucsome special cases.
619ebfedea0SLionel Sambuc
620ebfedea0SLionel SambucIn @code{des} there is the Kerberos 4 salt
621ebfedea0SLionel Sambuc(none at all) or the afs-salt (using the cell (realm in
622ebfedea0SLionel SambucAFS lingo)).
623ebfedea0SLionel Sambuc
624ebfedea0SLionel SambucIn @code{arcfour} (the encryption type that Microsoft Windows 2000 uses)
625ebfedea0SLionel Sambucthere is no salt. This is to be compatible with NTLM keys in Windows
626ebfedea0SLionel SambucNT 4.
627ebfedea0SLionel Sambuc
628ebfedea0SLionel Sambuc@code{[kadmin]default_keys} in @file{krb5.conf} controls
629ebfedea0SLionel Sambucwhat salting to use.
630ebfedea0SLionel Sambuc
631ebfedea0SLionel SambucThe syntax of @code{[kadmin]default_keys} is
632ebfedea0SLionel Sambuc@samp{[etype:]salt-type[:salt-string]}. @samp{etype} is the encryption
633ebfedea0SLionel Sambuctype (des-cbc-crc, arcfour-hmac-md5, aes256-cts-hmac-sha1-96),
634ebfedea0SLionel Sambuc@code{salt-type} is the type of salt (pw-salt or afs3-salt), and the
635ebfedea0SLionel Sambucsalt-string is the string that will be used as salt (remember that if
636ebfedea0SLionel Sambucthe salt is appended/prepended, the empty salt "" is the same thing as
637ebfedea0SLionel Sambucno salt at all).
638ebfedea0SLionel Sambuc
639ebfedea0SLionel SambucCommon types of salting include
640ebfedea0SLionel Sambuc
641ebfedea0SLionel Sambuc@itemize @bullet
642ebfedea0SLionel Sambuc@item @code{v4} (or @code{des:pw-salt:})
643ebfedea0SLionel Sambuc
644ebfedea0SLionel SambucThe Kerberos 4 salting is using no salt at all. Reason there is colon
645ebfedea0SLionel Sambucat the end of the salt string is that it makes the salt the empty
646ebfedea0SLionel Sambucstring (same as no salt).
647ebfedea0SLionel Sambuc
648ebfedea0SLionel Sambuc@item @code{v5} (or @code{pw-salt})
649ebfedea0SLionel Sambuc
650ebfedea0SLionel Sambuc@code{pw-salt} uses the default salt for each encryption type is
651ebfedea0SLionel Sambucspecified for. If the encryption type @samp{etype} isn't given, all
652ebfedea0SLionel Sambucdefault encryption will be used.
653ebfedea0SLionel Sambuc
654ebfedea0SLionel Sambuc@item @code{afs3-salt}
655ebfedea0SLionel Sambuc
656ebfedea0SLionel Sambuc@code{afs3-salt} is the salt that is used with Transarc kaserver. It's
657ebfedea0SLionel Sambucthe cell name appended to the password.
658ebfedea0SLionel Sambuc
659ebfedea0SLionel Sambuc@end itemize
660ebfedea0SLionel Sambuc
661ebfedea0SLionel Sambuc@node Credential cache server - KCM, Cross realm, Encryption types and salting, Setting up a realm
662ebfedea0SLionel Sambuc@section Credential cache server - KCM
663ebfedea0SLionel Sambuc@cindex KCM
664ebfedea0SLionel Sambuc@cindex Credential cache server
665ebfedea0SLionel Sambuc
666ebfedea0SLionel SambucWhen KCM running is easy for users to switch between different
667ebfedea0SLionel Sambuckerberos principals using @file{kswitch} or built in support in
668ebfedea0SLionel Sambucapplication, like OpenSSH's GSSAPIClientIdentity.
669ebfedea0SLionel Sambuc
670ebfedea0SLionel SambucOther advantages are that there is the long term credentials are not
671ebfedea0SLionel Sambucwritten to disk and on reboot the credential is removed when kcm
672ebfedea0SLionel Sambucprocess stopps running.
673ebfedea0SLionel Sambuc
674ebfedea0SLionel SambucConfigure the system startup script to start the kcm process,
675ebfedea0SLionel Sambuc@file{/usr/heimdal/libexec/kcm} and then configure the system to use kcm in @file{krb5.conf}.
676ebfedea0SLionel Sambuc
677ebfedea0SLionel Sambuc@example
678ebfedea0SLionel Sambuc[libdefaults]
679ebfedea0SLionel Sambuc	default_cc_type = KCM
680ebfedea0SLionel Sambuc@end example
681ebfedea0SLionel Sambuc
682ebfedea0SLionel SambucNow when you run @command{kinit} it doesn't overwrite your existing
683ebfedea0SLionel Sambuccredentials but rather just add them to the set of
684ebfedea0SLionel Sambuccredentials. @command{klist -l} lists the credentials and the star
685ebfedea0SLionel Sambucmarks the default credential.
686ebfedea0SLionel Sambuc
687ebfedea0SLionel Sambuc@example
688ebfedea0SLionel Sambuc$ kinit lha@@KTH.SE
689ebfedea0SLionel Sambuclha@@KTH.SE's Password:
690ebfedea0SLionel Sambuc$ klist -l
691ebfedea0SLionel Sambuc  Name         Cache name               Expires
692ebfedea0SLionel Sambuclha@@KTH.SE   0                        Nov 22 23:09:40   *
693ebfedea0SLionel Sambuclha@@SU.SE    Initial default ccache   Nov 22 14:14:24
694ebfedea0SLionel Sambuc@end example
695ebfedea0SLionel Sambuc
696ebfedea0SLionel SambucWhen switching between credentials you can use @command{kswitch}.
697ebfedea0SLionel Sambuc
698ebfedea0SLionel Sambuc@example
699ebfedea0SLionel Sambuc$ kswitch -i
700ebfedea0SLionel Sambuc     Principal
701ebfedea0SLionel Sambuc1    lha@@KTH.SE
702ebfedea0SLionel Sambuc2    lha@@SU.SE
703ebfedea0SLionel SambucSelect number: 2
704ebfedea0SLionel Sambuc@end example
705ebfedea0SLionel Sambuc
706ebfedea0SLionel SambucAfter switching, a new set of credentials are used as default.
707ebfedea0SLionel Sambuc
708ebfedea0SLionel Sambuc@example
709ebfedea0SLionel Sambuc$ klist -l
710ebfedea0SLionel Sambuc  Name         Cache name               Expires
711ebfedea0SLionel Sambuclha@@SU.SE    Initial default ccache   Nov 22 14:14:24   *
712ebfedea0SLionel Sambuclha@@KTH.SE   0                        Nov 22 23:09:40
713ebfedea0SLionel Sambuc@end example
714ebfedea0SLionel Sambuc
715ebfedea0SLionel SambucSom applications, like openssh with Simon Wilkinsons patch applied,
716ebfedea0SLionel Sambucsupport specifiying that credential to use.  The example below will
717ebfedea0SLionel Sambuclogin to the host computer.kth.se using lha@@KTH.SE (not the current
718ebfedea0SLionel Sambucdefault credential).
719ebfedea0SLionel Sambuc
720ebfedea0SLionel Sambuc@example
721ebfedea0SLionel Sambuc$ ssh \
722ebfedea0SLionel Sambuc   -o GSSAPIAuthentication=yes \
723ebfedea0SLionel Sambuc   -o GSSAPIKeyExchange=yes \
724ebfedea0SLionel Sambuc   -o GSSAPIClientIdentity=lha@@KTH.SE \
725ebfedea0SLionel Sambuc   computer.kth.se
726ebfedea0SLionel Sambuc@end example
727ebfedea0SLionel Sambuc
728ebfedea0SLionel Sambuc
729ebfedea0SLionel Sambuc
730ebfedea0SLionel Sambuc@node Cross realm, Transit policy, Credential cache server - KCM, Setting up a realm
731ebfedea0SLionel Sambuc@section Cross realm
732ebfedea0SLionel Sambuc@cindex Cross realm
733ebfedea0SLionel Sambuc
734ebfedea0SLionel SambucSuppose you reside in the realm @samp{MY.REALM}, how do you
735ebfedea0SLionel Sambucauthenticate to a server in @samp{OTHER.REALM}? Having valid tickets in
736ebfedea0SLionel Sambuc@samp{MY.REALM} allows you to communicate with Kerberised services in that
737ebfedea0SLionel Sambucrealm. However, the computer in the other realm does not have a secret
738ebfedea0SLionel Sambuckey shared with the Kerberos server in your realm.
739ebfedea0SLionel Sambuc
740ebfedea0SLionel SambucIt is possible to share keys between two realms that trust each
741ebfedea0SLionel Sambucother. When a client program, such as @command{telnet} or @command{ssh},
742ebfedea0SLionel Sambucfinds that the other computer is in a different realm, it will try to
743ebfedea0SLionel Sambucget a ticket granting ticket for that other realm, but from the local
744ebfedea0SLionel SambucKerberos server. With that ticket granting ticket, it will then obtain
745ebfedea0SLionel Sambucservice tickets from the Kerberos server in the other realm.
746ebfedea0SLionel Sambuc
747ebfedea0SLionel SambucFor a two way trust between @samp{MY.REALM} and @samp{OTHER.REALM}
748ebfedea0SLionel Sambucadd the following principals to each realm. The principals should be
749ebfedea0SLionel Sambuc@samp{krbtgt/OTHER.REALM@@MY.REALM} and
750ebfedea0SLionel Sambuc@samp{krbtgt/MY.REALM@@OTHER.REALM} in @samp{MY.REALM}, and
751ebfedea0SLionel Sambuc@samp{krbtgt/MY.REALM@@OTHER.REALM} and
752ebfedea0SLionel Sambuc@samp{krbtgt/OTHER.REALM@@MY.REALM}in @samp{OTHER.REALM}.
753ebfedea0SLionel Sambuc
754ebfedea0SLionel SambucIn Kerberos 5 the trust can be configured to be one way. So that
755ebfedea0SLionel Sambucusers from @samp{MY.REALM} can authenticate to services in
756ebfedea0SLionel Sambuc@samp{OTHER.REALM}, but not the opposite. In the example above, the
757ebfedea0SLionel Sambuc@samp{krbtgt/MY.REALM@@OTHER.REALM} then should be removed.
758ebfedea0SLionel Sambuc
759ebfedea0SLionel SambucThe two principals must have the same key, key version number, and the
760ebfedea0SLionel Sambucsame set of encryption types. Remember to transfer the two keys in a
761ebfedea0SLionel Sambucsafe manner.
762ebfedea0SLionel Sambuc
763ebfedea0SLionel Sambuc@example
764ebfedea0SLionel Sambucvr$ klist
765ebfedea0SLionel SambucCredentials cache: FILE:/tmp/krb5cc_913.console
766ebfedea0SLionel Sambuc        Principal: lha@@E.KTH.SE
767ebfedea0SLionel Sambuc
768ebfedea0SLionel Sambuc  Issued           Expires          Principal
769ebfedea0SLionel SambucMay  3 13:55:52  May  3 23:55:54  krbtgt/E.KTH.SE@@E.KTH.SE
770ebfedea0SLionel Sambuc
771ebfedea0SLionel Sambucvr$ telnet -l lha hummel.it.su.se
772ebfedea0SLionel SambucTrying 2001:6b0:5:1095:250:fcff:fe24:dbf...
773ebfedea0SLionel SambucConnected to hummel.it.su.se.
774ebfedea0SLionel SambucEscape character is '^]'.
775ebfedea0SLionel SambucWaiting for encryption to be negotiated...
776ebfedea0SLionel Sambuc[ Trying mutual KERBEROS5 (host/hummel.it.su.se@@SU.SE)... ]
777ebfedea0SLionel Sambuc[ Kerberos V5 accepts you as ``lha@@E.KTH.SE'' ]
778ebfedea0SLionel SambucEncryption negotiated.
779ebfedea0SLionel SambucLast login: Sat May  3 14:11:47 from vr.l.nxs.se
780ebfedea0SLionel Sambuchummel$ exit
781ebfedea0SLionel Sambuc
782ebfedea0SLionel Sambucvr$ klist
783ebfedea0SLionel SambucCredentials cache: FILE:/tmp/krb5cc_913.console
784ebfedea0SLionel Sambuc        Principal: lha@@E.KTH.SE
785ebfedea0SLionel Sambuc
786ebfedea0SLionel Sambuc  Issued           Expires          Principal
787ebfedea0SLionel SambucMay  3 13:55:52  May  3 23:55:54  krbtgt/E.KTH.SE@@E.KTH.SE
788ebfedea0SLionel SambucMay  3 13:55:56  May  3 23:55:54  krbtgt/SU.SE@@E.KTH.SE
789ebfedea0SLionel SambucMay  3 14:10:54  May  3 23:55:54  host/hummel.it.su.se@@SU.SE
790ebfedea0SLionel Sambuc
791ebfedea0SLionel Sambuc@end example
792ebfedea0SLionel Sambuc
793ebfedea0SLionel Sambuc@node Transit policy, Setting up DNS, Cross realm, Setting up a realm
794ebfedea0SLionel Sambuc@section Transit policy
795ebfedea0SLionel Sambuc@cindex Transit policy
796ebfedea0SLionel Sambuc
797ebfedea0SLionel SambucUnder some circumstances, you may not wish to set up direct
798ebfedea0SLionel Sambuccross-realm trust with every realm to which you wish to authenticate
799ebfedea0SLionel Sambucor from which you wish to accept authentications. Kerberos supports
800ebfedea0SLionel Sambucmulti-hop cross-realm trust where a client principal in realm A
801ebfedea0SLionel Sambucauthenticates to a service in realm C through a realm B with which
802ebfedea0SLionel Sambucboth A and C have cross-realm trust relationships. In this situation,
803ebfedea0SLionel SambucA and C need not set up cross-realm principals between each other.
804ebfedea0SLionel Sambuc
805ebfedea0SLionel SambucIf you want to use cross-realm authentication through an intermediate
806ebfedea0SLionel Sambucrealm, it must be explicitly allowed by either the KDCs for the realm
807ebfedea0SLionel Sambucto which the client is authenticating (in this case, realm C), or the
808ebfedea0SLionel Sambucserver receiving the request. This is done in @file{krb5.conf} in the
809ebfedea0SLionel Sambuc@code{[capaths]} section.
810ebfedea0SLionel Sambuc
811ebfedea0SLionel SambucIn addition, the client in realm A need to be configured to know how
812ebfedea0SLionel Sambucto reach realm C via realm B. This can be done either on the client or
813ebfedea0SLionel Sambucvia KDC configuration in the KDC for realm A.
814ebfedea0SLionel Sambuc
815ebfedea0SLionel Sambuc@subsection Allowing cross-realm transits
816ebfedea0SLionel Sambuc
817ebfedea0SLionel SambucWhen the ticket transits through a realm to another realm, the
818ebfedea0SLionel Sambucdestination realm adds its peer to the "transited-realms" field in the
819ebfedea0SLionel Sambucticket. The field is unordered, since there is no way to know if know
820ebfedea0SLionel Sambucif one of the transited-realms changed the order of the list. For the
821ebfedea0SLionel Sambucauthentication to be accepted by the final destination realm, all of
822ebfedea0SLionel Sambucthe transited realms must be listed as trusted in the @code{[capaths]}
823ebfedea0SLionel Sambucconfiguration, either in the KDC for the destination realm or on the
824ebfedea0SLionel Sambucserver receiving the authentication.
825ebfedea0SLionel Sambuc
826ebfedea0SLionel SambucThe syntax for @code{[capaths]} section is:
827ebfedea0SLionel Sambuc
828ebfedea0SLionel Sambuc@example
829ebfedea0SLionel Sambuc[capaths]
830ebfedea0SLionel Sambuc        CLIENT-REALM = @{
831ebfedea0SLionel Sambuc                SERVER-REALM = PERMITTED-CROSS-REALMS ...
832ebfedea0SLionel Sambuc        @}
833ebfedea0SLionel Sambuc@end example
834ebfedea0SLionel Sambuc
835ebfedea0SLionel SambucIn the following example, the realm @code{STACKEN.KTH.SE} only has
836ebfedea0SLionel Sambucdirect cross-realm set up with @code{KTH.SE}.  @code{KTH.SE} has
837ebfedea0SLionel Sambucdirect cross-realm set up with @code{STACKEN.KTH.SE} and @code{SU.SE}.
838ebfedea0SLionel Sambuc@code{DSV.SU.SE} only has direct cross-realm set up with @code{SU.SE}.
839ebfedea0SLionel SambucThe goal is to allow principals in the @code{DSV.SU.SE} or
840ebfedea0SLionel Sambuc@code{SU.SE} realms to authenticate to services in
841ebfedea0SLionel Sambuc@code{STACKEN.KTH.SE}.  This is done with the following
842ebfedea0SLionel Sambuc@code{[capaths]} entry on either the server accepting authentication
843ebfedea0SLionel Sambucor on the KDC for @code{STACKEN.KTH.SE}.
844ebfedea0SLionel Sambuc
845ebfedea0SLionel Sambuc@example
846ebfedea0SLionel Sambuc[capaths]
847ebfedea0SLionel Sambuc	SU.SE = @{
848ebfedea0SLionel Sambuc                    STACKEN.KTH.SE = KTH.SE
849ebfedea0SLionel Sambuc	@}
850ebfedea0SLionel Sambuc	DSV.SU.SE = @{
851ebfedea0SLionel Sambuc                    STACKEN.KTH.SE = SU.SE KTH.SE
852ebfedea0SLionel Sambuc	@}
853ebfedea0SLionel Sambuc@end example
854ebfedea0SLionel Sambuc
855ebfedea0SLionel SambucThe first entry allows cross-realm authentication from clients in
856ebfedea0SLionel Sambuc@code{SU.SE} transiting through @code{KTH.SE} to
857ebfedea0SLionel Sambuc@code{STACKEN.KTH.SE}.  The second entry allows cross-realm
858ebfedea0SLionel Sambucauthentication from clients in @code{DSV.SU.SE} transiting through
859ebfedea0SLionel Sambucboth @code{SU.SE} and @code{KTH.SE} to @code{STACKEN.KTH.SE}.
860ebfedea0SLionel Sambuc
861ebfedea0SLionel SambucBe careful of which realm goes where; it's easy to put realms in the
862ebfedea0SLionel Sambucwrong place.  The block is tagged with the client realm (the realm of
863ebfedea0SLionel Sambucthe principal authenticating), and the realm before the equal sign is
864ebfedea0SLionel Sambucthe final destination realm: the realm to which the client is
865ebfedea0SLionel Sambucauthenticating.  After the equal sign go all the realms that the
866ebfedea0SLionel Sambucclient transits through.
867ebfedea0SLionel Sambuc
868ebfedea0SLionel SambucThe order of the @code{PERMITTED-CROSS-REALMS} is not important when
869ebfedea0SLionel Sambucdoing transit cross realm verification.
870ebfedea0SLionel Sambuc
871ebfedea0SLionel Sambuc@subsection Configuring client cross-realm transits
872ebfedea0SLionel Sambuc
873ebfedea0SLionel SambucThe @code{[capaths]} section is also used for another purpose: to tell
874ebfedea0SLionel Sambucclients which realm to transit through to reach a realm with which
875ebfedea0SLionel Sambuctheir local realm does not have cross-realm trust.  This can be done
876ebfedea0SLionel Sambucby either putting a @code{[capaths]} entry in the configuration of the
877ebfedea0SLionel Sambucclient or by putting the entry in the configuration of the KDC for the
878ebfedea0SLionel Sambucclient's local realm.  In the latter case, the KDC will then hand back
879ebfedea0SLionel Sambuca referral to the client when the client requests a cross-realm ticket
880ebfedea0SLionel Sambucto the destination realm, telling the client to try to go through an
881ebfedea0SLionel Sambucintermediate realm.
882ebfedea0SLionel Sambuc
883ebfedea0SLionel SambucFor client configuration, the order of @code{PERMITTED-CROSS-REALMS}
884ebfedea0SLionel Sambucis significant, since only the first realm in this section (after the
885ebfedea0SLionel Sambucequal sign) is used by the client.
886ebfedea0SLionel Sambuc
887ebfedea0SLionel SambucFor example, again consider the @code{[capaths]} entry above for the
888ebfedea0SLionel Sambuccase of a client in the @code{SU.SE} realm, and assume that the client
889ebfedea0SLionel Sambucor the @code{SU.SE} KDC has that @code{[capaths]} entry.  If the
890ebfedea0SLionel Sambucclient attempts to authenticate to a service in the
891ebfedea0SLionel Sambuc@code{STACKEN.KTH.SE} realm, that entry says to first authenticate
892ebfedea0SLionel Sambuccross-realm to the @code{KTH.SE} realm (the first realm listed in the
893ebfedea0SLionel Sambuc@code{PERMITTED-CROSS-REALMS} section), and then from there to
894ebfedea0SLionel Sambuc@code{STACKEN.KTH.SE}.
895ebfedea0SLionel Sambuc
896ebfedea0SLionel SambucEach entry in @code{[capaths]} can only give the next hop, since only
897ebfedea0SLionel Sambucthe first realm in @code{PERMITTED-CROSS-REALMS} is used.  If, for
898ebfedea0SLionel Sambucinstance, a client in @code{DSV.SU.SE} had a @code{[capaths]}
899ebfedea0SLionel Sambucconfiguration as above but without the first block for @code{SU.SE},
900ebfedea0SLionel Sambucthey would not be able to reach @code{STACKEN.KTH.SE}.  They would get
901ebfedea0SLionel Sambucas far as @code{SU.SE} based on the @code{DSV.SU.SE} entry in
902ebfedea0SLionel Sambuc@code{[capaths]} and then attempt to go directly from there to
903ebfedea0SLionel Sambuc@code{STACKEN.KTH.SE} and get stuck (unless, of course, the
904ebfedea0SLionel Sambuc@code{SU.SE} KDC had the additional entry required to tell the client
905ebfedea0SLionel Sambucto go through @code{KTH.SE}).
906ebfedea0SLionel Sambuc
907ebfedea0SLionel Sambuc@subsection Active Directory forest example
908ebfedea0SLionel Sambuc
909ebfedea0SLionel SambucOne common place where a @code{[capaths]} configuration is desirable
910ebfedea0SLionel Sambucis with Windows Active Directory forests.  One common Active Directory
911ebfedea0SLionel Sambucconfiguration is to have one top-level Active Directory realm but then
912ebfedea0SLionel Sambucdivide systems, services, and users into child realms (perhaps based
913ebfedea0SLionel Sambucon organizational unit).  One generally establishes cross-realm trust
914ebfedea0SLionel Sambuconly with the top-level realm, and then uses transit policy to permit
915ebfedea0SLionel Sambucauthentications to and from the child realms.
916ebfedea0SLionel Sambuc
917ebfedea0SLionel SambucFor example, suppose an organization has a Heimdal realm
918ebfedea0SLionel Sambuc@code{EXAMPLE.COM}, a Windows Active Directory realm
919ebfedea0SLionel Sambuc@code{WIN.EXAMPLE.COM}, and then child Active Directory realms
920ebfedea0SLionel Sambuc@code{ENGR.WIN.EXAMPLE.COM} and @code{SALES.WIN.EXAMPLE.COM}.  The
921ebfedea0SLionel Sambucgoal is to allow users in any of these realms to authenticate to
922ebfedea0SLionel Sambucservices in any of these realms.  The @code{EXAMPLE.COM} KDC (and
923ebfedea0SLionel Sambucpossibly client) configuration should therefore contain a
924ebfedea0SLionel Sambuc@code{[capaths]} section as follows:
925ebfedea0SLionel Sambuc
926ebfedea0SLionel Sambuc@example
927ebfedea0SLionel Sambuc[capaths]
928ebfedea0SLionel Sambuc	ENGR.WIN.EXAMPLE.COM = @{
929ebfedea0SLionel Sambuc		EXAMPLE.COM = WIN.EXAMPLE.COM
930ebfedea0SLionel Sambuc	@}
931ebfedea0SLionel Sambuc	SALES.WIN.EXAMPLE.COM = @{
932ebfedea0SLionel Sambuc		EXAMPLE.COM = WIN.EXAMPLE.COM
933ebfedea0SLionel Sambuc	@}
934ebfedea0SLionel Sambuc	EXAMPLE.COM = @{
935ebfedea0SLionel Sambuc		ENGR.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM
936ebfedea0SLionel Sambuc		SALES.WIN.EXAMPLE.COM = WIN.EXAMPLE.COM
937ebfedea0SLionel Sambuc	@}
938ebfedea0SLionel Sambuc@end example
939ebfedea0SLionel Sambuc
940ebfedea0SLionel SambucThe first two blocks allow clients in the @code{ENGR.WIN.EXAMPLE.COM}
941ebfedea0SLionel Sambucand @code{SALES.WIN.EXAMPLE.COM} realms to authenticate to services in
942ebfedea0SLionel Sambucthe @code{EXAMPLE.COM} realm.  The third block tells the client (or
943ebfedea0SLionel Sambuctells the KDC to tell the client via referrals) to transit through
944ebfedea0SLionel Sambuc@code{WIN.EXAMPLE.COM} to reach these realms.  Both sides of the
945ebfedea0SLionel Sambucconfiguration are needed for bi-directional transited cross-realm
946ebfedea0SLionel Sambucauthentication.
947ebfedea0SLionel Sambuc
948ebfedea0SLionel Sambuc@c To test the cross realm configuration, use:
949ebfedea0SLionel Sambuc@c    kmumble transit-check client server transit-realms ...
950ebfedea0SLionel Sambuc
951ebfedea0SLionel Sambuc@node Setting up DNS, Using LDAP to store the database, Transit policy, Setting up a realm
952ebfedea0SLionel Sambuc@section Setting up DNS
953ebfedea0SLionel Sambuc@cindex Setting up DNS
954ebfedea0SLionel Sambuc
955ebfedea0SLionel Sambuc@subsection Using DNS to find KDC
956ebfedea0SLionel Sambuc
957ebfedea0SLionel SambucIf there is information about where to find the KDC or kadmind for a
958ebfedea0SLionel Sambucrealm in the @file{krb5.conf} for a realm, that information will be
959ebfedea0SLionel Sambucpreferred, and DNS will not be queried.
960ebfedea0SLionel Sambuc
961ebfedea0SLionel SambucHeimdal will try to use DNS to find the KDCs for a realm. First it
962ebfedea0SLionel Sambucwill try to find a @code{SRV} resource record (RR) for the realm. If no
963ebfedea0SLionel SambucSRV RRs are found, it will fall back to looking for an @code{A} RR for
964ebfedea0SLionel Sambuca machine named kerberos.REALM, and then kerberos-1.REALM, etc
965ebfedea0SLionel Sambuc
966ebfedea0SLionel SambucAdding this information to DNS minimises the client configuration (in
967ebfedea0SLionel Sambucthe common case, resulting in no configuration needed) and allows the
968ebfedea0SLionel Sambucsystem administrator to change the number of KDCs and on what machines
969ebfedea0SLionel Sambucthey are running without caring about clients.
970ebfedea0SLionel Sambuc
971ebfedea0SLionel SambucThe downside of using DNS is that the client might be fooled to use the
972ebfedea0SLionel Sambucwrong server if someone fakes DNS replies/data, but storing the IP
973ebfedea0SLionel Sambucaddresses of the KDC on all the clients makes it very hard to change
974ebfedea0SLionel Sambucthe infrastructure.
975ebfedea0SLionel Sambuc
976ebfedea0SLionel SambucAn example of the configuration for the realm @code{EXAMPLE.COM}:
977ebfedea0SLionel Sambuc
978ebfedea0SLionel Sambuc@example
979ebfedea0SLionel Sambuc
980ebfedea0SLionel Sambuc$ORIGIN example.com.
981ebfedea0SLionel Sambuc_kerberos._tcp          SRV     10 1 88 kerberos.example.com.
982ebfedea0SLionel Sambuc_kerberos._udp          SRV     10 1 88 kerberos.example.com.
983ebfedea0SLionel Sambuc_kerberos._tcp          SRV     10 1 88 kerberos-1.example.com.
984ebfedea0SLionel Sambuc_kerberos._udp          SRV     10 1 88 kerberos-1.example.com.
985ebfedea0SLionel Sambuc_kpasswd._udp           SRV     10 1 464 kerberos.example.com.
986ebfedea0SLionel Sambuc_kerberos-adm._tcp	SRV	10 1 749 kerberos.example.com.
987ebfedea0SLionel Sambuc
988ebfedea0SLionel Sambuc@end example
989ebfedea0SLionel Sambuc
990ebfedea0SLionel SambucMore information about DNS SRV resource records can be found in
991ebfedea0SLionel SambucRFC-2782 (A DNS RR for specifying the location of services (DNS SRV)).
992ebfedea0SLionel Sambuc
993ebfedea0SLionel Sambuc@subsection Using DNS to map hostname to Kerberos realm
994ebfedea0SLionel Sambuc
995ebfedea0SLionel SambucHeimdal also supports a way to lookup a realm from a hostname. This to
996ebfedea0SLionel Sambucminimise configuration needed on clients. Using this has the drawback
997ebfedea0SLionel Sambucthat clients can be redirected by an attacker to realms within the
998ebfedea0SLionel Sambucsame cross realm trust and made to believe they are talking to the
999ebfedea0SLionel Sambucright server (since Kerberos authentication will succeed).
1000ebfedea0SLionel Sambuc
1001ebfedea0SLionel SambucAn example configuration that informs clients that for the realms
1002ebfedea0SLionel Sambucit.example.com and srv.example.com, they should use the realm
1003ebfedea0SLionel SambucEXAMPLE.COM:
1004ebfedea0SLionel Sambuc
1005ebfedea0SLionel Sambuc@example
1006ebfedea0SLionel Sambuc
1007ebfedea0SLionel Sambuc$ORIGIN example.com.
1008ebfedea0SLionel Sambuc_kerberos.it		TXT     "EXAMPLE.COM"
1009ebfedea0SLionel Sambuc_kerberos.srv		TXT     "EXAMPLE.COM"
1010ebfedea0SLionel Sambuc
1011ebfedea0SLionel Sambuc@end example
1012ebfedea0SLionel Sambuc
1013ebfedea0SLionel Sambuc@node Using LDAP to store the database, Providing Kerberos credentials to servers and programs, Setting up DNS, Setting up a realm
1014ebfedea0SLionel Sambuc@section Using LDAP to store the database
1015ebfedea0SLionel Sambuc@cindex Using the LDAP backend
1016ebfedea0SLionel Sambuc
1017ebfedea0SLionel SambucThis document describes how to install the LDAP backend for
1018ebfedea0SLionel SambucHeimdal. Note that before attempting to configure such an
1019ebfedea0SLionel Sambucinstallation, you should be aware of the implications of storing
1020ebfedea0SLionel Sambucprivate information (such as users' keys) in a directory service
1021ebfedea0SLionel Sambucprimarily designed for public information. Nonetheless, with a
1022ebfedea0SLionel Sambucsuitable authorisation policy, it is possible to set this up in a
1023ebfedea0SLionel Sambucsecure fashion. A knowledge of LDAP, Kerberos, and C is necessary to
1024ebfedea0SLionel Sambucinstall this backend. The HDB schema was devised by Leif Johansson.
1025ebfedea0SLionel Sambuc
1026ebfedea0SLionel SambucThis assumes, OpenLDAP 2.3 or later.
1027ebfedea0SLionel Sambuc
1028ebfedea0SLionel SambucRequirements:
1029ebfedea0SLionel Sambuc
1030ebfedea0SLionel Sambuc@itemize @bullet
1031ebfedea0SLionel Sambuc
1032ebfedea0SLionel Sambuc@item
1033ebfedea0SLionel SambucA current release of Heimdal, configured with
1034ebfedea0SLionel Sambuc@code{--with-openldap=/usr/local} (adjust according to where you have
1035ebfedea0SLionel Sambucinstalled OpenLDAP).
1036ebfedea0SLionel Sambuc
1037ebfedea0SLionel SambucYou can verify that you manage to configure LDAP support by running
1038ebfedea0SLionel Sambuc@file{kdc --builtin-hdb}, and checking that @samp{ldap:} is one entry
1039ebfedea0SLionel Sambucin the list.
1040ebfedea0SLionel Sambuc
1041ebfedea0SLionel SambucIts also possible to configure the ldap backend as a shared module,
1042ebfedea0SLionel Sambucsee option --hdb-openldap-module to configure.
1043ebfedea0SLionel Sambuc
1044ebfedea0SLionel Sambuc@item
1045ebfedea0SLionel SambucConfigure OpenLDAP with @kbd{--enable-local} to enable the local transport.
1046ebfedea0SLionel Sambuc
1047ebfedea0SLionel Sambuc@item
1048ebfedea0SLionel SambucAdd the hdb schema to the LDAP server, it's included in the source-tree
1049ebfedea0SLionel Sambucin @file{lib/hdb/hdb.schema}. Example from slapd.conf:
1050ebfedea0SLionel Sambuc
1051ebfedea0SLionel Sambuc@example
1052ebfedea0SLionel Sambucinclude /usr/local/etc/openldap/schema/hdb.schema
1053ebfedea0SLionel Sambuc@end example
1054ebfedea0SLionel Sambuc
1055ebfedea0SLionel Sambuc@item
1056ebfedea0SLionel SambucConfigure the LDAP server ACLs to accept writes from clients over the
1057ebfedea0SLionel Sambuclocal transport. For example:
1058ebfedea0SLionel Sambuc
1059ebfedea0SLionel Sambuc@example
1060ebfedea0SLionel Sambucaccess to *
1061ebfedea0SLionel Sambuc        by dn.exact="uid=heimdal,dc=services,dc=example,dc=com" write
1062ebfedea0SLionel Sambuc        ...
1063ebfedea0SLionel Sambuc
1064ebfedea0SLionel Sambucauthz-regexp "gidNumber=.*\\\+uidNumber=0,cn=peercred,cn=external,cn=auth''
1065ebfedea0SLionel Sambuc	"uid=heimdal,dc=services,dc=example,dc=com"
1066ebfedea0SLionel Sambuc
1067ebfedea0SLionel Sambuc@end example
1068ebfedea0SLionel Sambuc
1069ebfedea0SLionel SambucThe sasl-regexp is for mapping between the SASL/EXTERNAL and a user in
1070ebfedea0SLionel Sambuca tree.  The user that the key is mapped to should be have a
1071ebfedea0SLionel Sambuckrb5Principal aux object with krb5PrincipalName set so that the
1072ebfedea0SLionel Sambuc``creator'' and ``modifier'' is right in @file{kadmin}.
1073ebfedea0SLionel Sambuc
1074ebfedea0SLionel SambucAnother option is to create an admins group and add the dn to that
1075ebfedea0SLionel Sambucgroup.
1076ebfedea0SLionel Sambuc
1077ebfedea0SLionel SambucSince Heimdal talks to the LDAP server over a UNIX domain socket, and
1078ebfedea0SLionel Sambucuses external sasl authentication, it's not possible to require
1079ebfedea0SLionel Sambucsecurity layer quality (ssf in cyrus-sasl lingo). So that requirement
1080ebfedea0SLionel Sambuchas to be turned off in OpenLDAP @command{slapd} configuration file
1081ebfedea0SLionel Sambuc@file{slapd.conf}.
1082ebfedea0SLionel Sambuc
1083ebfedea0SLionel Sambuc@example
1084ebfedea0SLionel Sambucsasl-secprops minssf=0
1085ebfedea0SLionel Sambuc@end example
1086ebfedea0SLionel Sambuc
1087ebfedea0SLionel Sambuc@item
1088ebfedea0SLionel Sambuc
1089ebfedea0SLionel SambucStart @command{slapd} with the local listener (as well as the default TCP/IP
1090ebfedea0SLionel Sambuclistener on port 389) as follows:
1091ebfedea0SLionel Sambuc
1092ebfedea0SLionel Sambuc@example
1093ebfedea0SLionel Sambuc    slapd -h "ldapi:/// ldap:///"
1094ebfedea0SLionel Sambuc@end example
1095ebfedea0SLionel Sambuc
1096ebfedea0SLionel SambucNote: These is a bug in @command{slapd} where it appears to corrupt the krb5Key
1097ebfedea0SLionel Sambucbinary attribute on shutdown. This may be related to our use of the V3
1098ebfedea0SLionel Sambucschema definition syntax instead of the old UMich-style, V2 syntax.
1099ebfedea0SLionel Sambuc
1100ebfedea0SLionel Sambuc@item
1101ebfedea0SLionel SambucYou should specify the distinguished name under which your
1102ebfedea0SLionel Sambucprincipals will be stored in @file{krb5.conf}. Also you need to
1103ebfedea0SLionel Sambucenter the path to the kadmin acl file:
1104ebfedea0SLionel Sambuc
1105ebfedea0SLionel Sambuc
1106ebfedea0SLionel Sambuc@example
1107ebfedea0SLionel Sambuc[kdc]
1108ebfedea0SLionel Sambuc        database = @{
1109ebfedea0SLionel Sambuc                dbname = ldap:ou=KerberosPrincipals,dc=example,dc=com
1110ebfedea0SLionel Sambuc                hdb-ldap-structural-object = inetOrgPerson
1111ebfedea0SLionel Sambuc                acl_file = /path/to/kadmind.acl
1112ebfedea0SLionel Sambuc                mkey_file = /path/to/mkey
1113ebfedea0SLionel Sambuc        @}
1114ebfedea0SLionel Sambuc@end example
1115ebfedea0SLionel Sambuc
1116ebfedea0SLionel Sambuc@samp{mkey_file} can be excluded if you feel that you trust your ldap
1117ebfedea0SLionel Sambucdirectory to have the raw keys inside it.  The
1118ebfedea0SLionel Sambuchdb-ldap-structural-object is not necessary if you do not need Samba
1119ebfedea0SLionel Sambuccomatibility.
1120ebfedea0SLionel Sambuc
1121ebfedea0SLionel Sambuc
1122ebfedea0SLionel Sambuc
1123ebfedea0SLionel Sambuc@item
1124ebfedea0SLionel SambucOnce you have built Heimdal and started the LDAP server, run kadmin
1125ebfedea0SLionel Sambuc(as usual) to initialise the database. Note that the instructions for
1126ebfedea0SLionel Sambucstashing a master key are as per any Heimdal installation.
1127ebfedea0SLionel Sambuc
1128ebfedea0SLionel Sambuc@example
1129ebfedea0SLionel Sambuckdc# kadmin -l
1130ebfedea0SLionel Sambuckadmin> init EXAMPLE.COM
1131ebfedea0SLionel SambucRealm max ticket life [unlimited]:
1132ebfedea0SLionel SambucRealm max renewable ticket life [unlimited]:
1133ebfedea0SLionel Sambuckadmin> add lukeh
1134ebfedea0SLionel SambucMax ticket life [1 day]:
1135ebfedea0SLionel SambucMax renewable life [1 week]:
1136ebfedea0SLionel SambucPrincipal expiration time [never]:
1137ebfedea0SLionel SambucPassword expiration time [never]:
1138ebfedea0SLionel SambucAttributes []:
1139ebfedea0SLionel Sambuclukeh@@EXAMPLE.COM's Password:
1140ebfedea0SLionel SambucVerifying password - lukeh@@EXAMPLE.COM's Password:
1141ebfedea0SLionel Sambuckadmin> exit
1142ebfedea0SLionel Sambuc@end example
1143ebfedea0SLionel Sambuc
1144ebfedea0SLionel SambucVerify that the principal database has indeed been stored in the
1145ebfedea0SLionel Sambucdirectory with the following command:
1146ebfedea0SLionel Sambuc
1147ebfedea0SLionel Sambuc@example
1148ebfedea0SLionel Sambuckdc# ldapsearch -L -h localhost -D cn=manager \
1149ebfedea0SLionel Sambuc -w secret -b ou=KerberosPrincipals,dc=example,dc=com \
1150ebfedea0SLionel Sambuc 'objectclass=krb5KDCEntry'
1151ebfedea0SLionel Sambuc@end example
1152ebfedea0SLionel Sambuc
1153ebfedea0SLionel Sambuc@item
1154ebfedea0SLionel SambucNow consider adding indexes to the database to speed up the access, at
1155ebfedea0SLionel Sambucleast theses should be added to slapd.conf.
1156ebfedea0SLionel Sambuc
1157ebfedea0SLionel Sambuc@example
1158ebfedea0SLionel Sambucindex	objectClass		eq
1159ebfedea0SLionel Sambucindex	cn			eq,sub,pres
1160ebfedea0SLionel Sambucindex	uid			eq,sub,pres
1161ebfedea0SLionel Sambucindex	displayName		eq,sub,pres
1162ebfedea0SLionel Sambucindex	krb5PrincipalName	eq
1163ebfedea0SLionel Sambuc@end example
1164ebfedea0SLionel Sambuc
1165ebfedea0SLionel Sambuc@end itemize
1166ebfedea0SLionel Sambuc
1167ebfedea0SLionel Sambuc@subsection smbk5pwd overlay
1168ebfedea0SLionel Sambuc
1169ebfedea0SLionel SambucThe smbk5pwd overlay, updates the krb5Key and krb5KeyVersionNumber
1170ebfedea0SLionel Sambucappropriately when it receives an LDAP Password change Extended
1171ebfedea0SLionel SambucOperation:
1172ebfedea0SLionel Sambuc
1173ebfedea0SLionel Sambuc@url{http://www.openldap.org/devel/cvsweb.cgi/contrib/slapd-modules/smbk5pwd/README?hideattic=1&sortbydate=0}
1174ebfedea0SLionel Sambuc
1175ebfedea0SLionel Sambuc@subsection Troubleshooting guide
1176ebfedea0SLionel Sambuc
1177ebfedea0SLionel Sambuc@url{https://sec.miljovern.no/bin/view/Info/TroubleshootingGuide}
1178ebfedea0SLionel Sambuc
1179ebfedea0SLionel Sambuc
1180ebfedea0SLionel Sambuc@subsection Using Samba LDAP password database
1181ebfedea0SLionel Sambuc@cindex Samba
1182ebfedea0SLionel Sambuc
1183ebfedea0SLionel Sambuc@c @node Using Samba LDAP password database, Providing Kerberos credentials to servers and programs, Using LDAP to store the database, Setting up a realm
1184ebfedea0SLionel Sambuc@c @section Using Samba LDAP password database
1185ebfedea0SLionel Sambuc
1186ebfedea0SLionel SambucThe Samba domain and the Kerberos realm can have different names since
1187ebfedea0SLionel Sambucarcfour's string to key functions principal/realm independent.  So now
1188ebfedea0SLionel Sambucwill be your first and only chance name your Kerberos realm without
1189ebfedea0SLionel Sambucneeding to deal with old configuration files.
1190ebfedea0SLionel Sambuc
1191ebfedea0SLionel SambucFirst, you should set up Samba and get that working with LDAP backend.
1192ebfedea0SLionel Sambuc
1193ebfedea0SLionel SambucNow you can proceed as in @xref{Using LDAP to store the database}.
1194ebfedea0SLionel SambucHeimdal will pick up the Samba LDAP entries if they are in the same
1195ebfedea0SLionel Sambucsearch space as the Kerberos entries.
1196ebfedea0SLionel Sambuc
1197ebfedea0SLionel Sambuc@node Providing Kerberos credentials to servers and programs, Setting up PK-INIT, Using LDAP to store the database, Setting up a realm
1198ebfedea0SLionel Sambuc@section Providing Kerberos credentials to servers and programs
1199ebfedea0SLionel Sambuc
1200ebfedea0SLionel SambucSome services require Kerberos credentials when they start to make
1201ebfedea0SLionel Sambucconnections to other services or need to use them when they have started.
1202ebfedea0SLionel Sambuc
1203ebfedea0SLionel SambucThe easiest way to get tickets for a service is to store the key in a
1204ebfedea0SLionel Sambuckeytab. Both ktutil get and kadmin ext can be used to get a
1205ebfedea0SLionel Sambuckeytab. ktutil get is better in that way it changes the key/password
1206ebfedea0SLionel Sambucfor the user. This is also the problem with ktutil. If ktutil is used
1207ebfedea0SLionel Sambucfor the same service principal on several hosts, they keytab will only
1208ebfedea0SLionel Sambucbe useful on the last host. In that case, run the extract command on
1209ebfedea0SLionel Sambucone host and then securely copy the keytab around to all other hosts
1210ebfedea0SLionel Sambucthat need it.
1211ebfedea0SLionel Sambuc
1212ebfedea0SLionel Sambuc@example
1213ebfedea0SLionel Sambuchost# ktutil -k /etc/krb5-service.keytab \
1214ebfedea0SLionel Sambuc      get -p lha/admin@@EXAMPLE.ORG service-principal@@EXAMPLE.ORG
1215ebfedea0SLionel Sambuclha/admin@@EXAMPLE.ORG's Password:
1216ebfedea0SLionel Sambuc@end example
1217ebfedea0SLionel Sambuc
1218ebfedea0SLionel SambucTo get a Kerberos credential file for the service, use kinit in the
1219ebfedea0SLionel Sambuc@kbd{--keytab} mode. This will not ask for a password but instead fetch the
1220ebfedea0SLionel Sambuckey from the keytab.
1221ebfedea0SLionel Sambuc
1222ebfedea0SLionel Sambuc@example
1223ebfedea0SLionel Sambucservice@@host$ kinit --cache=/var/run/service_krb5_cache \
1224ebfedea0SLionel Sambuc               --keytab=/etc/krb5-service.keytab \
1225ebfedea0SLionel Sambuc       service-principal@@EXAMPLE.ORG
1226ebfedea0SLionel Sambuc@end example
1227ebfedea0SLionel Sambuc
1228ebfedea0SLionel SambucLong running services might need credentials longer then the
1229ebfedea0SLionel Sambucexpiration time of the tickets. kinit can run in a mode that refreshes
1230ebfedea0SLionel Sambucthe tickets before they expire. This is useful for services that write
1231ebfedea0SLionel Sambucinto AFS and other distributed file systems using Kerberos. To run the
1232ebfedea0SLionel Sambuclong running script, just append the program and arguments (if any)
1233ebfedea0SLionel Sambucafter the principal. kinit will stop refreshing credentials and remove
1234ebfedea0SLionel Sambucthe credentials when the script-to-start-service exits.
1235ebfedea0SLionel Sambuc
1236ebfedea0SLionel Sambuc@example
1237ebfedea0SLionel Sambucservice@@host$ kinit --cache=/var/run/service_krb5_cache \
1238ebfedea0SLionel Sambuc       --keytab=/etc/krb5-service.keytab \
1239ebfedea0SLionel Sambuc       service-principal@@EXAMPLE.ORG \
1240ebfedea0SLionel Sambuc       script-to-start-service argument1 argument2
1241ebfedea0SLionel Sambuc@end example
1242ebfedea0SLionel Sambuc
1243ebfedea0SLionel Sambuc
1244ebfedea0SLionel Sambuc@node Setting up PK-INIT, Debugging Kerberos problems, Providing Kerberos credentials to servers and programs, Setting up a realm
1245ebfedea0SLionel Sambuc@section Setting up PK-INIT
1246ebfedea0SLionel Sambuc
1247ebfedea0SLionel SambucPK-INIT leverages an existing PKI (public key infrastructure), using
1248ebfedea0SLionel Sambuccertificates to get the initial ticket (usually the krbtgt
1249ebfedea0SLionel Sambucticket-granting ticket).
1250ebfedea0SLionel Sambuc
1251ebfedea0SLionel SambucTo use PK-INIT you must first have a PKI. If you don't have one, it is
1252ebfedea0SLionel Sambuctime to create it. You should first read the whole chapter of the
1253ebfedea0SLionel Sambucdocument to see the requirements imposed on the CA software.
1254ebfedea0SLionel Sambuc
1255ebfedea0SLionel SambucA mapping between the PKI certificate and what principals that
1256ebfedea0SLionel Sambuccertificate is allowed to use must exist. There are several ways to do
1257ebfedea0SLionel Sambucthis. The administrator can use a configuration file, store the
1258ebfedea0SLionel Sambucprincipal in the SubjectAltName extension of the certificate, or store
1259ebfedea0SLionel Sambucthe mapping in the principals entry in the kerberos database.
1260ebfedea0SLionel Sambuc
1261ebfedea0SLionel Sambuc@section Certificates
1262ebfedea0SLionel Sambuc
1263ebfedea0SLionel SambucThis section documents the requirements on the KDC and client
1264ebfedea0SLionel Sambuccertificates and the format used in the id-pkinit-san OtherName
1265ebfedea0SLionel Sambucextention.
1266ebfedea0SLionel Sambuc
1267ebfedea0SLionel Sambuc@subsection KDC certificate
1268ebfedea0SLionel Sambuc
1269ebfedea0SLionel SambucThe certificate for the KDC has serveral requirements.
1270ebfedea0SLionel Sambuc
1271ebfedea0SLionel SambucFirst, the certificate should have an Extended Key Usage (EKU)
1272ebfedea0SLionel Sambucid-pkkdcekuoid (1.3.6.1.5.2.3.5) set. Second, there must be a
1273ebfedea0SLionel SambucsubjectAltName otherName using OID id-pkinit-san (1.3.6.1.5.2.2) in
1274ebfedea0SLionel Sambucthe type field and a DER encoded KRB5PrincipalName that matches the
1275ebfedea0SLionel Sambucname of the TGS of the target realm.  Also, if the certificate has a
1276ebfedea0SLionel SambucnameConstraints extention with a Generalname with dNSName or iPAdress,
1277ebfedea0SLionel Sambucit must match the hostname or adress of the KDC.
1278ebfedea0SLionel Sambuc
1279ebfedea0SLionel SambucThe client is not required by the standard to check the server
1280ebfedea0SLionel Sambuccertificate for this information if the client has external
1281ebfedea0SLionel Sambucinformation confirming which certificate the KDC is supposed to be
1282ebfedea0SLionel Sambucusing. However, adding this information to the KDC certificate removes
1283ebfedea0SLionel Sambucthe need to specially configure the client to recognize the KDC
1284ebfedea0SLionel Sambuccertificate.
1285ebfedea0SLionel Sambuc
1286ebfedea0SLionel SambucRemember that if the client would accept any certificate as the KDC's
1287ebfedea0SLionel Sambuccertificate, the client could be fooled into trusting something that
1288ebfedea0SLionel Sambucisn't a KDC and thus expose the user to giving away information (like
1289ebfedea0SLionel Sambuca password or other private information) that it is supposed to keep
1290ebfedea0SLionel Sambucsecret.
1291ebfedea0SLionel Sambuc
1292ebfedea0SLionel Sambuc@subsection Client certificate
1293ebfedea0SLionel Sambuc
1294ebfedea0SLionel SambucThe client certificate may need to have a EKU id-pkekuoid
1295ebfedea0SLionel Sambuc(1.3.6.1.5.2.3.4) set depending on the certifiate on the KDC.
1296ebfedea0SLionel Sambuc
1297ebfedea0SLionel SambucIt possible to store the principal (if allowed by the KDC) in the
1298ebfedea0SLionel Sambuccertificate and thus delegate responsibility to do the mapping between
1299ebfedea0SLionel Sambuccertificates and principals to the CA.
1300ebfedea0SLionel Sambuc
1301ebfedea0SLionel SambucThis behavior is controlled by KDC configuration option:
1302ebfedea0SLionel Sambuc
1303ebfedea0SLionel Sambuc@example
1304ebfedea0SLionel Sambuc[kdc]
1305ebfedea0SLionel Sambuc	pkinit_principal_in_certificate = yes
1306ebfedea0SLionel Sambuc@end example
1307ebfedea0SLionel Sambuc
1308ebfedea0SLionel Sambuc@subsubsection Using KRB5PrincipalName in id-pkinit-san
1309ebfedea0SLionel Sambuc
1310ebfedea0SLionel SambucThe OtherName extention in the GeneralName is used to do the mapping
1311ebfedea0SLionel Sambucbetween certificate and principal.  For the KDC certificate, this
1312ebfedea0SLionel Sambucstores the krbtgt principal name for that KDC.  For the client
1313ebfedea0SLionel Sambuccertificate, this stores the principal for which that certificate is
1314ebfedea0SLionel Sambucallowed to get tickets.
1315ebfedea0SLionel Sambuc
1316ebfedea0SLionel SambucThe principal is stored in a SubjectAltName in the certificate using
1317ebfedea0SLionel SambucOtherName. The OID in the type is id-pkinit-san.
1318ebfedea0SLionel Sambuc
1319ebfedea0SLionel Sambuc@example
1320ebfedea0SLionel Sambucid-pkinit-san OBJECT IDENTIFIER ::= @{ iso (1) org (3) dod (6)
1321ebfedea0SLionel Sambucinternet (1) security (5) kerberosv5 (2) 2 @}
1322ebfedea0SLionel Sambuc@end example
1323ebfedea0SLionel Sambuc
1324ebfedea0SLionel SambucThe data part of the OtherName is filled with the following DER
1325ebfedea0SLionel Sambucencoded ASN.1 structure:
1326ebfedea0SLionel Sambuc
1327ebfedea0SLionel Sambuc@example
1328ebfedea0SLionel SambucKRB5PrincipalName ::= SEQUENCE @{
1329ebfedea0SLionel Sambuc	realm [0] Realm,
1330ebfedea0SLionel Sambuc	principalName [1] PrincipalName
1331ebfedea0SLionel Sambuc@}
1332ebfedea0SLionel Sambuc@end example
1333ebfedea0SLionel Sambuc
1334ebfedea0SLionel Sambucwhere Realm and PrincipalName is defined by the Kerberos ASN.1
1335ebfedea0SLionel Sambucspecification.
1336ebfedea0SLionel Sambuc
1337ebfedea0SLionel Sambuc@section Naming certificate using hx509
1338ebfedea0SLionel Sambuc
1339ebfedea0SLionel Sambuchx509 is the X.509 software used in Heimdal to handle
1340ebfedea0SLionel Sambuccertificates. hx509 supports several different syntaxes for specifying
1341ebfedea0SLionel Sambuccertificate files or formats. Several formats may be used:  PEM,
1342ebfedea0SLionel Sambuccertificates embedded in PKCS#12 files, certificates embedded in
1343ebfedea0SLionel SambucPKCS#11 devices, and raw DER encoded certificates.
1344ebfedea0SLionel Sambuc
1345ebfedea0SLionel SambucThose formats may be specified as follows:
1346ebfedea0SLionel Sambuc
1347ebfedea0SLionel Sambuc@table @asis
1348ebfedea0SLionel Sambuc
1349ebfedea0SLionel Sambuc@item DIR:
1350ebfedea0SLionel Sambuc
1351ebfedea0SLionel SambucDIR specifies a directory which contains certificates in the DER or
1352ebfedea0SLionel SambucPEM format.
1353ebfedea0SLionel Sambuc
1354ebfedea0SLionel SambucThe main feature of DIR is that the directory is read on demand when
1355ebfedea0SLionel Sambuciterating over certificates. This allows applications, in some
1356ebfedea0SLionel Sambucsituations, to avoid having to store all certificates in memory.  It's
1357ebfedea0SLionel Sambucvery useful for tests that iterate over large numbers of certificates.
1358ebfedea0SLionel Sambuc
1359ebfedea0SLionel SambucThe syntax is:
1360ebfedea0SLionel Sambuc
1361ebfedea0SLionel Sambuc@example
1362ebfedea0SLionel SambucDIR:/path/to/der/files
1363ebfedea0SLionel Sambuc@end example
1364ebfedea0SLionel Sambuc
1365ebfedea0SLionel Sambuc@item FILE:
1366ebfedea0SLionel Sambuc
1367ebfedea0SLionel SambucFILE: specifies a file that contains a certificate or private key.
1368ebfedea0SLionel SambucThe file can be either a PEM (openssl) file or a raw DER encoded
1369ebfedea0SLionel Sambuccertificate. If it's a PEM file, it can contain several keys and
1370ebfedea0SLionel Sambuccertificates and the code will try to match the private key and
1371ebfedea0SLionel Sambuccertificate together. Multiple files may be specified, separated by
1372ebfedea0SLionel Sambuccommas.
1373ebfedea0SLionel Sambuc
1374ebfedea0SLionel SambucIt's useful to have one PEM file that contains all the trust anchors.
1375ebfedea0SLionel Sambuc
1376ebfedea0SLionel SambucThe syntax is:
1377ebfedea0SLionel Sambuc
1378ebfedea0SLionel Sambuc@example
1379ebfedea0SLionel SambucFILE:certificate.pem,private-key.key,other-cert.pem,....
1380ebfedea0SLionel Sambuc@end example
1381ebfedea0SLionel Sambuc
1382ebfedea0SLionel Sambuc@item PKCS11:
1383ebfedea0SLionel Sambuc
1384ebfedea0SLionel SambucPKCS11: is used to handle smartcards via PKCS#11 drivers, such as
1385ebfedea0SLionel Sambucsoft-token, opensc, or muscle. The argument specifies a shared object
1386ebfedea0SLionel Sambucthat implements the PKCS#11 API. The default is to use all slots on
1387ebfedea0SLionel Sambucthe device/token.
1388ebfedea0SLionel Sambuc
1389ebfedea0SLionel SambucThe syntax is:
1390ebfedea0SLionel Sambuc
1391ebfedea0SLionel Sambuc@example
1392ebfedea0SLionel SambucPKCS11:shared-object.so
1393ebfedea0SLionel Sambuc@end example
1394ebfedea0SLionel Sambuc
1395ebfedea0SLionel Sambuc@item PKCS12:
1396ebfedea0SLionel Sambuc
1397ebfedea0SLionel SambucPKCS12: is used to handle PKCS#12 files. PKCS#12 files commonly have
1398ebfedea0SLionel Sambucthe extension pfx or p12.
1399ebfedea0SLionel Sambuc
1400ebfedea0SLionel SambucThe syntax is:
1401ebfedea0SLionel Sambuc
1402ebfedea0SLionel Sambuc@example
1403ebfedea0SLionel SambucPKCS12:/path/to/file.pfx
1404ebfedea0SLionel Sambuc@end example
1405ebfedea0SLionel Sambuc
1406ebfedea0SLionel Sambuc@end table
1407ebfedea0SLionel Sambuc
1408ebfedea0SLionel Sambuc@section Configure the Kerberos software
1409ebfedea0SLionel Sambuc
1410ebfedea0SLionel SambucFirst configure the client's trust anchors and what parameters to
1411ebfedea0SLionel Sambucverify. See the subsections below for how to do that. Then, you can
1412ebfedea0SLionel Sambucuse kinit to get yourself tickets. For example:
1413ebfedea0SLionel Sambuc
1414ebfedea0SLionel Sambuc@example
1415ebfedea0SLionel Sambuc$ kinit -C FILE:$HOME/.certs/lha.crt,$HOME/.certs/lha.key lha@@EXAMPLE.ORG
1416ebfedea0SLionel SambucEnter your private key passphrase:
1417ebfedea0SLionel Sambuc: lha@@nutcracker ; klist
1418ebfedea0SLionel SambucCredentials cache: FILE:/tmp/krb5cc_19100a
1419ebfedea0SLionel Sambuc        Principal: lha@@EXAMPLE.ORG
1420ebfedea0SLionel Sambuc
1421ebfedea0SLionel Sambuc  Issued           Expires          Principal
1422ebfedea0SLionel SambucApr 20 02:08:08  Apr 20 12:08:08  krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
1423ebfedea0SLionel Sambuc@end example
1424ebfedea0SLionel Sambuc
1425ebfedea0SLionel SambucUsing PKCS#11 it can look like this instead:
1426ebfedea0SLionel Sambuc
1427ebfedea0SLionel Sambuc@example
1428ebfedea0SLionel Sambuc$ kinit -C PKCS11:/usr/heimdal/lib/hx509.so lha@@EXAMPLE.ORG
1429ebfedea0SLionel SambucPIN code for SoftToken (slot):
1430ebfedea0SLionel Sambuc$ klist
1431ebfedea0SLionel SambucCredentials cache: API:4
1432ebfedea0SLionel Sambuc        Principal: lha@@EXAMPLE.ORG
1433ebfedea0SLionel Sambuc
1434ebfedea0SLionel Sambuc  Issued           Expires          Principal
1435ebfedea0SLionel SambucMar 26 23:40:10  Mar 27 09:40:10  krbtgt/EXAMPLE.ORG@@EXAMPLE.ORG
1436ebfedea0SLionel Sambuc@end example
1437ebfedea0SLionel Sambuc
1438ebfedea0SLionel SambucTODO: Write about the KDC.
1439ebfedea0SLionel Sambuc
1440ebfedea0SLionel Sambuc@section Configure the client
1441ebfedea0SLionel Sambuc
1442ebfedea0SLionel Sambuc@example
1443ebfedea0SLionel Sambuc[appdefaults]
1444ebfedea0SLionel Sambuc	pkinit_anchors = FILE:/path/to/trust-anchors.pem
1445ebfedea0SLionel Sambuc
1446ebfedea0SLionel Sambuc[realms]
1447ebfedea0SLionel Sambuc        EXAMPLE.COM = @{
1448ebfedea0SLionel Sambuc		pkinit_require_eku = true
1449ebfedea0SLionel Sambuc		pkinit_require_krbtgt_otherName = true
1450ebfedea0SLionel Sambuc		pkinit_win2k = no
1451ebfedea0SLionel Sambuc		pkinit_win2k_require_binding = yes
1452ebfedea0SLionel Sambuc	@}
1453ebfedea0SLionel Sambuc
1454ebfedea0SLionel Sambuc@end example
1455ebfedea0SLionel Sambuc
1456ebfedea0SLionel Sambuc@section Configure the KDC
1457ebfedea0SLionel Sambuc
1458ebfedea0SLionel Sambuc@example
1459ebfedea0SLionel Sambuc[kdc]
1460ebfedea0SLionel Sambuc	enable-pkinit = yes
1461ebfedea0SLionel Sambuc	pkinit_identity = FILE:/secure/kdc.crt,/secure/kdc.key
1462ebfedea0SLionel Sambuc	pkinit_anchors = FILE:/path/to/trust-anchors.pem
1463ebfedea0SLionel Sambuc	pkinit_pool = PKCS12:/path/to/useful-intermediate-certs.pfx
1464ebfedea0SLionel Sambuc	pkinit_pool = FILE:/path/to/other-useful-intermediate-certs.pem
1465ebfedea0SLionel Sambuc	pkinit_allow_proxy_certificate = no
1466ebfedea0SLionel Sambuc	pkinit_win2k_require_binding = yes
1467ebfedea0SLionel Sambuc	pkinit_principal_in_certificate = no
1468ebfedea0SLionel Sambuc@end example
1469ebfedea0SLionel Sambuc
1470ebfedea0SLionel Sambuc@subsection Using pki-mapping file
1471ebfedea0SLionel Sambuc
1472ebfedea0SLionel SambucNote that the file name is space sensitive.
1473ebfedea0SLionel Sambuc
1474ebfedea0SLionel Sambuc@example
1475ebfedea0SLionel Sambuc# cat /var/heimdal/pki-mapping
1476ebfedea0SLionel Sambuc# comments starts with #
1477ebfedea0SLionel Sambuclha@@EXAMPLE.ORG:C=SE,O=Stockholm universitet,CN=Love,UID=lha
1478ebfedea0SLionel Sambuclha@@EXAMPLE.ORG:CN=Love,UID=lha
1479ebfedea0SLionel Sambuc@end example
1480ebfedea0SLionel Sambuc
1481ebfedea0SLionel Sambuc@subsection Using the Kerberos database
1482ebfedea0SLionel Sambuc
1483ebfedea0SLionel Sambuc@section Use hxtool to create certificates
1484ebfedea0SLionel Sambuc
1485ebfedea0SLionel Sambuc@subsection Generate certificates
1486ebfedea0SLionel Sambuc
1487ebfedea0SLionel SambucFirst, you need to generate a CA certificate. This example creates a
1488ebfedea0SLionel SambucCA certificate that will be valid for 10 years.
1489ebfedea0SLionel Sambuc
1490ebfedea0SLionel SambucYou need to change --subject in the command below to something
1491ebfedea0SLionel Sambucappropriate for your site.
1492ebfedea0SLionel Sambuc
1493ebfedea0SLionel Sambuc@example
1494ebfedea0SLionel Sambuchxtool issue-certificate \
1495ebfedea0SLionel Sambuc    --self-signed \
1496ebfedea0SLionel Sambuc    --issue-ca \
1497ebfedea0SLionel Sambuc    --generate-key=rsa \
1498ebfedea0SLionel Sambuc    --subject="CN=CA,DC=test,DC=h5l,DC=se" \
1499ebfedea0SLionel Sambuc    --lifetime=10years \
1500ebfedea0SLionel Sambuc    --certificate="FILE:ca.pem"
1501ebfedea0SLionel Sambuc@end example
1502ebfedea0SLionel Sambuc
1503ebfedea0SLionel SambucThe KDC needs to have a certificate, so generate a certificate of the
1504ebfedea0SLionel Sambuctype ``pkinit-kdc'' and set the PK-INIT specifial SubjectAltName to the
1505ebfedea0SLionel Sambucname of the krbtgt of the realm.
1506ebfedea0SLionel Sambuc
1507ebfedea0SLionel SambucYou need to change --subject and --pk-init-principal in the command
1508ebfedea0SLionel Sambucbelow to something appropriate for your site.
1509ebfedea0SLionel Sambuc
1510ebfedea0SLionel Sambuc@example
1511ebfedea0SLionel Sambuchxtool issue-certificate \
1512ebfedea0SLionel Sambuc    --ca-certificate=FILE:ca.pem \
1513ebfedea0SLionel Sambuc    --generate-key=rsa \
1514ebfedea0SLionel Sambuc    --type="pkinit-kdc" \
1515ebfedea0SLionel Sambuc    --pk-init-principal="krbtgt/TEST.H5L.SE@@TEST.H5L.SE" \
1516ebfedea0SLionel Sambuc    --subject="uid=kdc,DC=test,DC=h5l,DC=se" \
1517ebfedea0SLionel Sambuc    --certificate="FILE:kdc.pem"
1518ebfedea0SLionel Sambuc@end example
1519ebfedea0SLionel Sambuc
1520ebfedea0SLionel SambucThe users also needs to have certificates. For your first client,
1521ebfedea0SLionel Sambucgenerate a certificate of type ``pkinit-client''. The client doesn't
1522ebfedea0SLionel Sambucneed to have the PK-INIT SubjectAltName set; you can have the Subject
1523ebfedea0SLionel SambucDN in the ACL file (pki-mapping) instead.
1524ebfedea0SLionel Sambuc
1525ebfedea0SLionel SambucYou need to change --subject and --pk-init-principal in the command
1526ebfedea0SLionel Sambucbelow to something appropriate for your site. You can omit
1527ebfedea0SLionel Sambuc--pk-init-principal if you're going to use the ACL file instead.
1528ebfedea0SLionel Sambuc
1529ebfedea0SLionel Sambuc@example
1530ebfedea0SLionel Sambuchxtool issue-certificate \
1531ebfedea0SLionel Sambuc    --ca-certificate=FILE:ca.pem \
1532ebfedea0SLionel Sambuc    --generate-key=rsa \
1533ebfedea0SLionel Sambuc    --type="pkinit-client" \
1534ebfedea0SLionel Sambuc    --pk-init-principal="lha@@TEST.H5L.SE" \
1535ebfedea0SLionel Sambuc    --subject="uid=lha,DC=test,DC=h5l,DC=se" \
1536ebfedea0SLionel Sambuc    --certificate="FILE:user.pem"
1537ebfedea0SLionel Sambuc@end example
1538ebfedea0SLionel Sambuc
1539ebfedea0SLionel Sambuc@subsection Validate the certificate
1540ebfedea0SLionel Sambuc
1541ebfedea0SLionel Sambuchxtool also contains a tool that will validate certificates according
1542ebfedea0SLionel Sambucto rules from the PKIX document. These checks are not complete, but
1543ebfedea0SLionel Sambucthey provide a good test of whether you got all of the basic bits
1544ebfedea0SLionel Sambucright in your certificates.
1545ebfedea0SLionel Sambuc
1546ebfedea0SLionel Sambuc@example
1547ebfedea0SLionel Sambuchxtool validate FILE:user.pem
1548ebfedea0SLionel Sambuc@end example
1549ebfedea0SLionel Sambuc
1550ebfedea0SLionel Sambuc@section Use OpenSSL to create certificates
1551ebfedea0SLionel Sambuc
1552ebfedea0SLionel SambucThis section tries to give the CA owners hints how to create
1553ebfedea0SLionel Sambuccertificates using OpenSSL (or CA software based on OpenSSL).
1554ebfedea0SLionel Sambuc
1555ebfedea0SLionel Sambuc@subsection Using OpenSSL to create certificates with krb5PrincipalName
1556ebfedea0SLionel Sambuc
1557ebfedea0SLionel SambucTo make OpenSSL create certificates with krb5PrincipalName, use an
1558ebfedea0SLionel Sambuc@file{openssl.cnf} as described below. To see a complete example of
1559ebfedea0SLionel Sambuccreating client and KDC certificates, see the test-data generation
1560ebfedea0SLionel Sambucscript @file{lib/hx509/data/gen-req.sh} in the source-tree. The
1561ebfedea0SLionel Sambuccerticates it creates are used to test the PK-INIT functionality in
1562ebfedea0SLionel Sambuc@file{tests/kdc/check-kdc.in}.
1563ebfedea0SLionel Sambuc
1564ebfedea0SLionel SambucTo use this example you have to use OpenSSL 0.9.8a or later.
1565ebfedea0SLionel Sambuc
1566ebfedea0SLionel Sambuc@example
1567ebfedea0SLionel Sambuc
1568ebfedea0SLionel Sambuc[user_certificate]
1569ebfedea0SLionel SambucsubjectAltName=otherName:1.3.6.1.5.2.2;SEQUENCE:princ_name
1570ebfedea0SLionel Sambuc
1571ebfedea0SLionel Sambuc[princ_name]
1572ebfedea0SLionel Sambucrealm = EXP:0, GeneralString:MY.REALM
1573ebfedea0SLionel Sambucprincipal_name = EXP:1, SEQUENCE:principal_seq
1574ebfedea0SLionel Sambuc
1575ebfedea0SLionel Sambuc[principal_seq]
1576ebfedea0SLionel Sambucname_type = EXP:0, INTEGER:1
1577ebfedea0SLionel Sambucname_string = EXP:1, SEQUENCE:principals
1578ebfedea0SLionel Sambuc
1579ebfedea0SLionel Sambuc[principals]
1580ebfedea0SLionel Sambucprinc1 = GeneralString:userid
1581ebfedea0SLionel Sambuc
1582ebfedea0SLionel Sambuc@end example
1583ebfedea0SLionel Sambuc
1584ebfedea0SLionel SambucCommand usage:
1585ebfedea0SLionel Sambuc
1586ebfedea0SLionel Sambuc@example
1587ebfedea0SLionel Sambucopenssl x509 -extensions user_certificate
1588ebfedea0SLionel Sambucopenssl ca -extensions user_certificate
1589ebfedea0SLionel Sambuc@end example
1590ebfedea0SLionel Sambuc
1591ebfedea0SLionel Sambuc
1592ebfedea0SLionel Sambuc@c --- ms certificate
1593ebfedea0SLionel Sambuc@c
1594ebfedea0SLionel Sambuc@c [ new_oids ]
1595ebfedea0SLionel Sambuc@c msCertificateTemplateName       = 1.3.6.1.4.1.311.20.2
1596ebfedea0SLionel Sambuc@c
1597ebfedea0SLionel Sambuc@c
1598ebfedea0SLionel Sambuc@c [ req_smartcard ]
1599ebfedea0SLionel Sambuc@c keyUsage                = digitalSignature, keyEncipherment
1600ebfedea0SLionel Sambuc@c extendedKeyUsage        = msSmartcardLogin, clientAuth
1601ebfedea0SLionel Sambuc@c msCertificateTemplateName       = ASN1:BMP:SmartcardLogon
1602ebfedea0SLionel Sambuc@c subjectAltName          = otherName:msUPN;UTF8:lukeh@dsg.padl.com
1603ebfedea0SLionel Sambuc@c #subjectAltName         = email:copy
1604ebfedea0SLionel Sambuc
1605ebfedea0SLionel Sambuc
1606ebfedea0SLionel Sambuc@section Using PK-INIT with Windows
1607ebfedea0SLionel Sambuc
1608ebfedea0SLionel Sambuc@subsection Client configration
1609ebfedea0SLionel Sambuc
1610ebfedea0SLionel SambucClients using a Windows KDC with PK-INIT need configuration since
1611ebfedea0SLionel Sambucwindows uses pre-standard format and this can't be autodetected.
1612ebfedea0SLionel Sambuc
1613ebfedea0SLionel SambucThe pkinit_win2k_require_binding option requires the reply for the KDC
1614ebfedea0SLionel Sambucto be of the new, secure, type that binds the request to
1615ebfedea0SLionel Sambucreply. Before, clients could fake the reply from the KDC. To use this
1616ebfedea0SLionel Sambucoption you have to apply a fix from Microsoft.
1617ebfedea0SLionel Sambuc
1618ebfedea0SLionel Sambuc@example
1619ebfedea0SLionel Sambuc[realms]
1620ebfedea0SLionel Sambuc        MY.MS.REALM = @{
1621ebfedea0SLionel Sambuc                pkinit_win2k = yes
1622ebfedea0SLionel Sambuc                pkinit_win2k_require_binding = no
1623ebfedea0SLionel Sambuc	@}
1624ebfedea0SLionel Sambuc@end example
1625ebfedea0SLionel Sambuc
1626ebfedea0SLionel Sambuc@subsection Certificates
1627ebfedea0SLionel Sambuc
1628ebfedea0SLionel SambucThe client certificates need to have the extended keyusage ``Microsoft
1629ebfedea0SLionel SambucSmartcardlogin'' (openssl has the OID shortname msSmartcardLogin).
1630ebfedea0SLionel Sambuc
1631ebfedea0SLionel SambucSee Microsoft Knowledge Base Article - 281245 ``Guidelines for Enabling
1632ebfedea0SLionel SambucSmart Card Logon with Third-Party Certification Authorities'' for a
1633ebfedea0SLionel Sambucmore extensive description of how set setup an external CA so that it
1634ebfedea0SLionel Sambucincludes all the information required to make a Windows KDC happy.
1635ebfedea0SLionel Sambuc
1636ebfedea0SLionel Sambuc@subsection Configure Windows 2000 CA
1637ebfedea0SLionel Sambuc
1638ebfedea0SLionel SambucTo enable Microsoft Smartcardlogin for certificates in your Windows
1639ebfedea0SLionel Sambuc2000 CA, you want to look at Microsoft Knowledge Base Article - 313274
1640ebfedea0SLionel Sambuc``HOW TO: Configure a Certification Authority to Issue Smart Card
1641ebfedea0SLionel SambucCertificates in Windows''.
1642ebfedea0SLionel Sambuc
1643ebfedea0SLionel Sambuc@node Debugging Kerberos problems, , Setting up PK-INIT, Setting up a realm
1644ebfedea0SLionel Sambuc@section Debugging Kerberos problems
1645ebfedea0SLionel Sambuc
1646ebfedea0SLionel SambucTo debug Kerberos client and server problems you can enable debug
1647ebfedea0SLionel Sambuctraceing by adding the following to @file{/etc/krb5,conf}. Note that the
1648ebfedea0SLionel Sambuctrace logging is sparse at the moment, but will continue to improve.
1649ebfedea0SLionel Sambuc
1650ebfedea0SLionel Sambuc@example
1651ebfedea0SLionel Sambuc[logging]
1652ebfedea0SLionel Sambuc        libkrb5 = 0-/SYSLOG:
1653ebfedea0SLionel Sambuc@end example
1654ebfedea0SLionel Sambuc
1655ebfedea0SLionel Sambuc
1656ebfedea0SLionel Sambuc
1657ebfedea0SLionel Sambuc
1658