xref: /freebsd/crypto/krb5/doc/user/tkt_mgmt.rst (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy SchubertTicket management
2*7f2fe78bSCy Schubert=================
3*7f2fe78bSCy Schubert
4*7f2fe78bSCy SchubertOn many systems, Kerberos is built into the login program, and you get
5*7f2fe78bSCy Schuberttickets automatically when you log in.  Other programs, such as ssh,
6*7f2fe78bSCy Schubertcan forward copies of your tickets to a remote host.  Most of these
7*7f2fe78bSCy Schubertprograms also automatically destroy your tickets when they exit.
8*7f2fe78bSCy SchubertHowever, MIT recommends that you explicitly destroy your Kerberos
9*7f2fe78bSCy Schuberttickets when you are through with them, just to be sure.  One way to
10*7f2fe78bSCy Schuberthelp ensure that this happens is to add the :ref:`kdestroy(1)` command
11*7f2fe78bSCy Schubertto your .logout file.  Additionally, if you are going to be away from
12*7f2fe78bSCy Schubertyour machine and are concerned about an intruder using your
13*7f2fe78bSCy Schubertpermissions, it is safest to either destroy all copies of your
14*7f2fe78bSCy Schuberttickets, or use a screensaver that locks the screen.
15*7f2fe78bSCy Schubert
16*7f2fe78bSCy Schubert
17*7f2fe78bSCy SchubertKerberos ticket properties
18*7f2fe78bSCy Schubert--------------------------
19*7f2fe78bSCy Schubert
20*7f2fe78bSCy SchubertThere are various properties that Kerberos tickets can have:
21*7f2fe78bSCy Schubert
22*7f2fe78bSCy SchubertIf a ticket is **forwardable**, then the KDC can issue a new ticket
23*7f2fe78bSCy Schubert(with a different network address, if necessary) based on the
24*7f2fe78bSCy Schubertforwardable ticket.  This allows for authentication forwarding without
25*7f2fe78bSCy Schubertrequiring a password to be typed in again.  For example, if a user
26*7f2fe78bSCy Schubertwith a forwardable TGT logs into a remote system, the KDC could issue
27*7f2fe78bSCy Schuberta new TGT for that user with the network address of the remote system,
28*7f2fe78bSCy Schubertallowing authentication on that host to work as though the user were
29*7f2fe78bSCy Schubertlogged in locally.
30*7f2fe78bSCy Schubert
31*7f2fe78bSCy SchubertWhen the KDC creates a new ticket based on a forwardable ticket, it
32*7f2fe78bSCy Schubertsets the **forwarded** flag on that new ticket.  Any tickets that are
33*7f2fe78bSCy Schubertcreated based on a ticket with the forwarded flag set will also have
34*7f2fe78bSCy Schuberttheir forwarded flags set.
35*7f2fe78bSCy Schubert
36*7f2fe78bSCy SchubertA **proxiable** ticket is similar to a forwardable ticket in that it
37*7f2fe78bSCy Schubertallows a service to take on the identity of the client.  Unlike a
38*7f2fe78bSCy Schubertforwardable ticket, however, a proxiable ticket is only issued for
39*7f2fe78bSCy Schubertspecific services.  In other words, a ticket-granting ticket cannot be
40*7f2fe78bSCy Schubertissued based on a ticket that is proxiable but not forwardable.
41*7f2fe78bSCy Schubert
42*7f2fe78bSCy SchubertA **proxy** ticket is one that was issued based on a proxiable ticket.
43*7f2fe78bSCy Schubert
44*7f2fe78bSCy SchubertA **postdated** ticket is issued with the invalid flag set.  After the
45*7f2fe78bSCy Schubertstarting time listed on the ticket, it can be presented to the KDC to
46*7f2fe78bSCy Schubertobtain valid tickets.
47*7f2fe78bSCy Schubert
48*7f2fe78bSCy SchubertTicket-granting tickets with the **postdateable** flag set can be used
49*7f2fe78bSCy Schubertto obtain postdated service tickets.
50*7f2fe78bSCy Schubert
51*7f2fe78bSCy Schubert**Renewable** tickets can be used to obtain new session keys without
52*7f2fe78bSCy Schubertthe user entering their password again.  A renewable ticket has two
53*7f2fe78bSCy Schubertexpiration times.  The first is the time at which this particular
54*7f2fe78bSCy Schubertticket expires.  The second is the latest possible expiration time for
55*7f2fe78bSCy Schubertany ticket issued based on this renewable ticket.
56*7f2fe78bSCy Schubert
57*7f2fe78bSCy SchubertA ticket with the **initial flag** set was issued based on the
58*7f2fe78bSCy Schubertauthentication protocol, and not on a ticket-granting ticket.
59*7f2fe78bSCy SchubertApplication servers that wish to ensure that the user's key has been
60*7f2fe78bSCy Schubertrecently presented for verification could specify that this flag must
61*7f2fe78bSCy Schubertbe set to accept the ticket.
62*7f2fe78bSCy Schubert
63*7f2fe78bSCy SchubertAn **invalid** ticket must be rejected by application servers.
64*7f2fe78bSCy SchubertPostdated tickets are usually issued with this flag set, and must be
65*7f2fe78bSCy Schubertvalidated by the KDC before they can be used.
66*7f2fe78bSCy Schubert
67*7f2fe78bSCy SchubertA **preauthenticated** ticket is one that was only issued after the
68*7f2fe78bSCy Schubertclient requesting the ticket had authenticated itself to the KDC.
69*7f2fe78bSCy Schubert
70*7f2fe78bSCy SchubertThe **hardware authentication** flag is set on a ticket which required
71*7f2fe78bSCy Schubertthe use of hardware for authentication.  The hardware is expected to
72*7f2fe78bSCy Schubertbe possessed only by the client which requested the tickets.
73*7f2fe78bSCy Schubert
74*7f2fe78bSCy SchubertIf a ticket has the **transit policy** checked flag set, then the KDC
75*7f2fe78bSCy Schubertthat issued this ticket implements the transited-realm check policy
76*7f2fe78bSCy Schubertand checked the transited-realms list on the ticket.  The
77*7f2fe78bSCy Schuberttransited-realms list contains a list of all intermediate realms
78*7f2fe78bSCy Schubertbetween the realm of the KDC that issued the first ticket and that of
79*7f2fe78bSCy Schubertthe one that issued the current ticket.  If this flag is not set, then
80*7f2fe78bSCy Schubertthe application server must check the transited realms itself or else
81*7f2fe78bSCy Schubertreject the ticket.
82*7f2fe78bSCy Schubert
83*7f2fe78bSCy SchubertThe **okay as delegate** flag indicates that the server specified in
84*7f2fe78bSCy Schubertthe ticket is suitable as a delegate as determined by the policy of
85*7f2fe78bSCy Schubertthat realm.  Some client applications may use this flag to decide
86*7f2fe78bSCy Schubertwhether to forward tickets to a remote host, although many
87*7f2fe78bSCy Schubertapplications do not honor it.
88*7f2fe78bSCy Schubert
89*7f2fe78bSCy SchubertAn **anonymous** ticket is one in which the named principal is a
90*7f2fe78bSCy Schubertgeneric principal for that realm; it does not actually specify the
91*7f2fe78bSCy Schubertindividual that will be using the ticket.  This ticket is meant only
92*7f2fe78bSCy Schubertto securely distribute a session key.
93*7f2fe78bSCy Schubert
94*7f2fe78bSCy Schubert
95*7f2fe78bSCy Schubert.. _obtain_tkt:
96*7f2fe78bSCy Schubert
97*7f2fe78bSCy SchubertObtaining tickets with kinit
98*7f2fe78bSCy Schubert----------------------------
99*7f2fe78bSCy Schubert
100*7f2fe78bSCy SchubertIf your site has integrated Kerberos V5 with the login system, you
101*7f2fe78bSCy Schubertwill get Kerberos tickets automatically when you log in.  Otherwise,
102*7f2fe78bSCy Schubertyou may need to explicitly obtain your Kerberos tickets, using the
103*7f2fe78bSCy Schubert:ref:`kinit(1)` program.  Similarly, if your Kerberos tickets expire,
104*7f2fe78bSCy Schubertuse the kinit program to obtain new ones.
105*7f2fe78bSCy Schubert
106*7f2fe78bSCy SchubertTo use the kinit program, simply type ``kinit`` and then type your
107*7f2fe78bSCy Schubertpassword at the prompt. For example, Jennifer (whose username is
108*7f2fe78bSCy Schubert``jennifer``) works for Bleep, Inc. (a fictitious company with the
109*7f2fe78bSCy Schubertdomain name mit.edu and the Kerberos realm ATHENA.MIT.EDU).  She would
110*7f2fe78bSCy Schuberttype::
111*7f2fe78bSCy Schubert
112*7f2fe78bSCy Schubert    shell% kinit
113*7f2fe78bSCy Schubert    Password for jennifer@ATHENA.MIT.EDU: <-- [Type jennifer's password here.]
114*7f2fe78bSCy Schubert    shell%
115*7f2fe78bSCy Schubert
116*7f2fe78bSCy SchubertIf you type your password incorrectly, kinit will give you the
117*7f2fe78bSCy Schubertfollowing error message::
118*7f2fe78bSCy Schubert
119*7f2fe78bSCy Schubert    shell% kinit
120*7f2fe78bSCy Schubert    Password for jennifer@ATHENA.MIT.EDU: <-- [Type the wrong password here.]
121*7f2fe78bSCy Schubert    kinit: Password incorrect
122*7f2fe78bSCy Schubert    shell%
123*7f2fe78bSCy Schubert
124*7f2fe78bSCy Schubertand you won't get Kerberos tickets.
125*7f2fe78bSCy Schubert
126*7f2fe78bSCy SchubertBy default, kinit assumes you want tickets for your own username in
127*7f2fe78bSCy Schubertyour default realm.  Suppose Jennifer's friend David is visiting, and
128*7f2fe78bSCy Schuberthe wants to borrow a window to check his mail.  David needs to get
129*7f2fe78bSCy Schuberttickets for himself in his own realm, EXAMPLE.COM.  He would type::
130*7f2fe78bSCy Schubert
131*7f2fe78bSCy Schubert    shell% kinit david@EXAMPLE.COM
132*7f2fe78bSCy Schubert    Password for david@EXAMPLE.COM: <-- [Type david's password here.]
133*7f2fe78bSCy Schubert    shell%
134*7f2fe78bSCy Schubert
135*7f2fe78bSCy SchubertDavid would then have tickets which he could use to log onto his own
136*7f2fe78bSCy Schubertmachine.  Note that he typed his password locally on Jennifer's
137*7f2fe78bSCy Schubertmachine, but it never went over the network.  Kerberos on the local
138*7f2fe78bSCy Schuberthost performed the authentication to the KDC in the other realm.
139*7f2fe78bSCy Schubert
140*7f2fe78bSCy SchubertIf you want to be able to forward your tickets to another host, you
141*7f2fe78bSCy Schubertneed to request forwardable tickets.  You do this by specifying the
142*7f2fe78bSCy Schubert**-f** option::
143*7f2fe78bSCy Schubert
144*7f2fe78bSCy Schubert    shell% kinit -f
145*7f2fe78bSCy Schubert    Password for jennifer@ATHENA.MIT.EDU: <-- [Type your password here.]
146*7f2fe78bSCy Schubert    shell%
147*7f2fe78bSCy Schubert
148*7f2fe78bSCy SchubertNote that kinit does not tell you that it obtained forwardable
149*7f2fe78bSCy Schuberttickets; you can verify this using the :ref:`klist(1)` command (see
150*7f2fe78bSCy Schubert:ref:`view_tkt`).
151*7f2fe78bSCy Schubert
152*7f2fe78bSCy SchubertNormally, your tickets are good for your system's default ticket
153*7f2fe78bSCy Schubertlifetime, which is ten hours on many systems.  You can specify a
154*7f2fe78bSCy Schubertdifferent ticket lifetime with the **-l** option.  Add the letter
155*7f2fe78bSCy Schubert**s** to the value for seconds, **m** for minutes, **h** for hours, or
156*7f2fe78bSCy Schubert**d** for days.  For example, to obtain forwardable tickets for
157*7f2fe78bSCy Schubert``david@EXAMPLE.COM`` that would be good for three hours, you would
158*7f2fe78bSCy Schuberttype::
159*7f2fe78bSCy Schubert
160*7f2fe78bSCy Schubert    shell% kinit -f -l 3h david@EXAMPLE.COM
161*7f2fe78bSCy Schubert    Password for david@EXAMPLE.COM: <-- [Type david's password here.]
162*7f2fe78bSCy Schubert    shell%
163*7f2fe78bSCy Schubert
164*7f2fe78bSCy Schubert.. note::
165*7f2fe78bSCy Schubert
166*7f2fe78bSCy Schubert          You cannot mix units; specifying a lifetime of 3h30m would
167*7f2fe78bSCy Schubert          result in an error.  Note also that most systems specify a
168*7f2fe78bSCy Schubert          maximum ticket lifetime.  If you request a longer ticket
169*7f2fe78bSCy Schubert          lifetime, it will be automatically truncated to the maximum
170*7f2fe78bSCy Schubert          lifetime.
171*7f2fe78bSCy Schubert
172*7f2fe78bSCy Schubert
173*7f2fe78bSCy Schubert.. _view_tkt:
174*7f2fe78bSCy Schubert
175*7f2fe78bSCy SchubertViewing tickets with klist
176*7f2fe78bSCy Schubert--------------------------
177*7f2fe78bSCy Schubert
178*7f2fe78bSCy SchubertThe :ref:`klist(1)` command shows your tickets.  When you first obtain
179*7f2fe78bSCy Schuberttickets, you will have only the ticket-granting ticket.  The listing
180*7f2fe78bSCy Schubertwould look like this::
181*7f2fe78bSCy Schubert
182*7f2fe78bSCy Schubert    shell% klist
183*7f2fe78bSCy Schubert    Ticket cache: /tmp/krb5cc_ttypa
184*7f2fe78bSCy Schubert    Default principal: jennifer@ATHENA.MIT.EDU
185*7f2fe78bSCy Schubert
186*7f2fe78bSCy Schubert    Valid starting     Expires            Service principal
187*7f2fe78bSCy Schubert    06/07/04 19:49:21  06/08/04 05:49:19  krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
188*7f2fe78bSCy Schubert    shell%
189*7f2fe78bSCy Schubert
190*7f2fe78bSCy SchubertThe ticket cache is the location of your ticket file. In the above
191*7f2fe78bSCy Schubertexample, this file is named ``/tmp/krb5cc_ttypa``. The default
192*7f2fe78bSCy Schubertprincipal is your Kerberos principal.
193*7f2fe78bSCy Schubert
194*7f2fe78bSCy SchubertThe "valid starting" and "expires" fields describe the period of time
195*7f2fe78bSCy Schubertduring which the ticket is valid.  The "service principal" describes
196*7f2fe78bSCy Schuberteach ticket.  The ticket-granting ticket has a first component
197*7f2fe78bSCy Schubert``krbtgt``, and a second component which is the realm name.
198*7f2fe78bSCy Schubert
199*7f2fe78bSCy SchubertNow, if ``jennifer`` connected to the machine ``daffodil.mit.edu``,
200*7f2fe78bSCy Schubertand then typed "klist" again, she would have gotten the following
201*7f2fe78bSCy Schubertresult::
202*7f2fe78bSCy Schubert
203*7f2fe78bSCy Schubert    shell% klist
204*7f2fe78bSCy Schubert    Ticket cache: /tmp/krb5cc_ttypa
205*7f2fe78bSCy Schubert    Default principal: jennifer@ATHENA.MIT.EDU
206*7f2fe78bSCy Schubert
207*7f2fe78bSCy Schubert    Valid starting     Expires            Service principal
208*7f2fe78bSCy Schubert    06/07/04 19:49:21  06/08/04 05:49:19  krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
209*7f2fe78bSCy Schubert    06/07/04 20:22:30  06/08/04 05:49:19  host/daffodil.mit.edu@ATHENA.MIT.EDU
210*7f2fe78bSCy Schubert    shell%
211*7f2fe78bSCy Schubert
212*7f2fe78bSCy SchubertHere's what happened: when ``jennifer`` used ssh to connect to the
213*7f2fe78bSCy Schuberthost ``daffodil.mit.edu``, the ssh program presented her
214*7f2fe78bSCy Schubertticket-granting ticket to the KDC and requested a host ticket for the
215*7f2fe78bSCy Schuberthost ``daffodil.mit.edu``.  The KDC sent the host ticket, which ssh
216*7f2fe78bSCy Schubertthen presented to the host ``daffodil.mit.edu``, and she was allowed
217*7f2fe78bSCy Schubertto log in without typing her password.
218*7f2fe78bSCy Schubert
219*7f2fe78bSCy SchubertSuppose your Kerberos tickets allow you to log into a host in another
220*7f2fe78bSCy Schubertdomain, such as ``trillium.example.com``, which is also in another
221*7f2fe78bSCy SchubertKerberos realm, ``EXAMPLE.COM``.  If you ssh to this host, you will
222*7f2fe78bSCy Schubertreceive a ticket-granting ticket for the realm ``EXAMPLE.COM``, plus
223*7f2fe78bSCy Schubertthe new host ticket for ``trillium.example.com``.  klist will now
224*7f2fe78bSCy Schubertshow::
225*7f2fe78bSCy Schubert
226*7f2fe78bSCy Schubert    shell% klist
227*7f2fe78bSCy Schubert    Ticket cache: /tmp/krb5cc_ttypa
228*7f2fe78bSCy Schubert    Default principal: jennifer@ATHENA.MIT.EDU
229*7f2fe78bSCy Schubert
230*7f2fe78bSCy Schubert    Valid starting     Expires            Service principal
231*7f2fe78bSCy Schubert    06/07/04 19:49:21  06/08/04 05:49:19  krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
232*7f2fe78bSCy Schubert    06/07/04 20:22:30  06/08/04 05:49:19  host/daffodil.mit.edu@ATHENA.MIT.EDU
233*7f2fe78bSCy Schubert    06/07/04 20:24:18  06/08/04 05:49:19  krbtgt/EXAMPLE.COM@ATHENA.MIT.EDU
234*7f2fe78bSCy Schubert    06/07/04 20:24:18  06/08/04 05:49:19  host/trillium.example.com@EXAMPLE.COM
235*7f2fe78bSCy Schubert    shell%
236*7f2fe78bSCy Schubert
237*7f2fe78bSCy SchubertDepending on your host's and realm's configuration, you may also see a
238*7f2fe78bSCy Schubertticket with the service principal ``host/trillium.example.com@``.  If
239*7f2fe78bSCy Schubertso, this means that your host did not know what realm
240*7f2fe78bSCy Schuberttrillium.example.com is in, so it asked the ``ATHENA.MIT.EDU`` KDC for
241*7f2fe78bSCy Schuberta referral.  The next time you connect to ``trillium.example.com``,
242*7f2fe78bSCy Schubertthe odd-looking entry will be used to avoid needing to ask for a
243*7f2fe78bSCy Schubertreferral again.
244*7f2fe78bSCy Schubert
245*7f2fe78bSCy SchubertYou can use the **-f** option to view the flags that apply to your
246*7f2fe78bSCy Schuberttickets.  The flags are:
247*7f2fe78bSCy Schubert
248*7f2fe78bSCy Schubert===== =========================
249*7f2fe78bSCy Schubert  F   Forwardable
250*7f2fe78bSCy Schubert  f   forwarded
251*7f2fe78bSCy Schubert  P   Proxiable
252*7f2fe78bSCy Schubert  p   proxy
253*7f2fe78bSCy Schubert  D   postDateable
254*7f2fe78bSCy Schubert  d   postdated
255*7f2fe78bSCy Schubert  R   Renewable
256*7f2fe78bSCy Schubert  I   Initial
257*7f2fe78bSCy Schubert  i   invalid
258*7f2fe78bSCy Schubert  H   Hardware authenticated
259*7f2fe78bSCy Schubert  A   preAuthenticated
260*7f2fe78bSCy Schubert  T   Transit policy checked
261*7f2fe78bSCy Schubert  O   Okay as delegate
262*7f2fe78bSCy Schubert  a   anonymous
263*7f2fe78bSCy Schubert===== =========================
264*7f2fe78bSCy Schubert
265*7f2fe78bSCy SchubertHere is a sample listing.  In this example, the user *jennifer*
266*7f2fe78bSCy Schubertobtained her initial tickets (**I**), which are forwardable (**F**)
267*7f2fe78bSCy Schubertand postdated (**d**) but not yet validated (**i**)::
268*7f2fe78bSCy Schubert
269*7f2fe78bSCy Schubert    shell% klist -f
270*7f2fe78bSCy Schubert    Ticket cache: /tmp/krb5cc_320
271*7f2fe78bSCy Schubert    Default principal: jennifer@ATHENA.MIT.EDU
272*7f2fe78bSCy Schubert
273*7f2fe78bSCy Schubert    Valid starting      Expires             Service principal
274*7f2fe78bSCy Schubert    31/07/05 19:06:25  31/07/05 19:16:25  krbtgt/ATHENA.MIT.EDU@ATHENA.MIT.EDU
275*7f2fe78bSCy Schubert            Flags: FdiI
276*7f2fe78bSCy Schubert    shell%
277*7f2fe78bSCy Schubert
278*7f2fe78bSCy SchubertIn the following example, the user *david*'s tickets were forwarded
279*7f2fe78bSCy Schubert(**f**) to this host from another host.  The tickets are reforwardable
280*7f2fe78bSCy Schubert(**F**)::
281*7f2fe78bSCy Schubert
282*7f2fe78bSCy Schubert    shell% klist -f
283*7f2fe78bSCy Schubert    Ticket cache: /tmp/krb5cc_p11795
284*7f2fe78bSCy Schubert    Default principal: david@EXAMPLE.COM
285*7f2fe78bSCy Schubert
286*7f2fe78bSCy Schubert    Valid starting     Expires            Service principal
287*7f2fe78bSCy Schubert    07/31/05 11:52:29  07/31/05 21:11:23  krbtgt/EXAMPLE.COM@EXAMPLE.COM
288*7f2fe78bSCy Schubert            Flags: Ff
289*7f2fe78bSCy Schubert    07/31/05 12:03:48  07/31/05 21:11:23  host/trillium.example.com@EXAMPLE.COM
290*7f2fe78bSCy Schubert            Flags: Ff
291*7f2fe78bSCy Schubert    shell%
292*7f2fe78bSCy Schubert
293*7f2fe78bSCy Schubert
294*7f2fe78bSCy SchubertDestroying tickets with kdestroy
295*7f2fe78bSCy Schubert--------------------------------
296*7f2fe78bSCy Schubert
297*7f2fe78bSCy SchubertYour Kerberos tickets are proof that you are indeed yourself, and
298*7f2fe78bSCy Schuberttickets could be stolen if someone gains access to a computer where
299*7f2fe78bSCy Schubertthey are stored.  If this happens, the person who has them can
300*7f2fe78bSCy Schubertmasquerade as you until they expire.  For this reason, you should
301*7f2fe78bSCy Schubertdestroy your Kerberos tickets when you are away from your computer.
302*7f2fe78bSCy Schubert
303*7f2fe78bSCy SchubertDestroying your tickets is easy.  Simply type kdestroy::
304*7f2fe78bSCy Schubert
305*7f2fe78bSCy Schubert    shell% kdestroy
306*7f2fe78bSCy Schubert    shell%
307*7f2fe78bSCy Schubert
308*7f2fe78bSCy SchubertIf :ref:`kdestroy(1)` fails to destroy your tickets, it will beep and
309*7f2fe78bSCy Schubertgive an error message.  For example, if kdestroy can't find any
310*7f2fe78bSCy Schuberttickets to destroy, it will give the following message::
311*7f2fe78bSCy Schubert
312*7f2fe78bSCy Schubert    shell% kdestroy
313*7f2fe78bSCy Schubert    kdestroy: No credentials cache file found while destroying cache
314*7f2fe78bSCy Schubert    shell%
315