1*7f2fe78bSCy SchubertPrincipal names and DNS 2*7f2fe78bSCy Schubert======================= 3*7f2fe78bSCy Schubert 4*7f2fe78bSCy SchubertKerberos clients can do DNS lookups to canonicalize service principal 5*7f2fe78bSCy Schubertnames. This can cause difficulties when setting up Kerberos 6*7f2fe78bSCy Schubertapplication servers, especially when the client's name for the service 7*7f2fe78bSCy Schubertis different from what the service thinks its name is. 8*7f2fe78bSCy Schubert 9*7f2fe78bSCy Schubert 10*7f2fe78bSCy SchubertService principal names 11*7f2fe78bSCy Schubert----------------------- 12*7f2fe78bSCy Schubert 13*7f2fe78bSCy SchubertA frequently used kind of principal name is the host-based service 14*7f2fe78bSCy Schubertprincipal name. This kind of principal name has two components: a 15*7f2fe78bSCy Schubertservice name and a hostname. For example, ``imap/imap.example.com`` 16*7f2fe78bSCy Schubertis the principal name of the "imap" service on the host 17*7f2fe78bSCy Schubert"imap.example.com". Other possible service names for the first 18*7f2fe78bSCy Schubertcomponent include "host" (remote login services such as ssh), "HTTP", 19*7f2fe78bSCy Schubertand "nfs" (Network File System). 20*7f2fe78bSCy Schubert 21*7f2fe78bSCy SchubertService administrators often publish well-known hostname aliases that 22*7f2fe78bSCy Schubertthey would prefer users to use instead of the canonical name of the 23*7f2fe78bSCy Schubertservice host. This gives service administrators more flexibility in 24*7f2fe78bSCy Schubertdeploying services. For example, a shell login server might be named 25*7f2fe78bSCy Schubert"long-vanity-hostname.example.com", but users will naturally prefer to 26*7f2fe78bSCy Schuberttype something like "login.example.com". Hostname aliases also allow 27*7f2fe78bSCy Schubertfor administrators to set up load balancing for some sorts of services 28*7f2fe78bSCy Schubertbased on rotating ``CNAME`` records in DNS. 29*7f2fe78bSCy Schubert 30*7f2fe78bSCy Schubert 31*7f2fe78bSCy SchubertService principal canonicalization 32*7f2fe78bSCy Schubert---------------------------------- 33*7f2fe78bSCy Schubert 34*7f2fe78bSCy SchubertIn the MIT krb5 client library, canonicalization of host-based service 35*7f2fe78bSCy Schubertprincipals is controlled by the **dns_canonicalize_hostname**, 36*7f2fe78bSCy Schubert**rnds**, and **qualify_shortname** variables in :ref:`libdefaults`. 37*7f2fe78bSCy Schubert 38*7f2fe78bSCy SchubertIf **dns_canonicalize_hostname** is set to ``true`` (the default 39*7f2fe78bSCy Schubertvalue), the client performs forward resolution by looking up the IPv4 40*7f2fe78bSCy Schubertand/or IPv6 addresses of the hostname using ``getaddrinfo()``. This 41*7f2fe78bSCy Schubertprocess will typically add a domain suffix to the hostname if needed, 42*7f2fe78bSCy Schubertand follow CNAME records in the DNS. If **rdns** is also set to 43*7f2fe78bSCy Schubert``true`` (the default), the client will then perform a reverse lookup 44*7f2fe78bSCy Schubertof the first returned Internet address using ``getnameinfo()``, 45*7f2fe78bSCy Schubertfinding the name associated with the PTR record. 46*7f2fe78bSCy Schubert 47*7f2fe78bSCy SchubertIf **dns_canonicalize_hostname** is set to ``false``, the hostname is 48*7f2fe78bSCy Schubertnot canonicalized using DNS. If the hostname has only one component 49*7f2fe78bSCy Schubert(i.e. it contains no "." characters), the host's primary DNS search 50*7f2fe78bSCy Schubertdomain will be appended, if there is one. The **qualify_shortname** 51*7f2fe78bSCy Schubertvariable can be used to override or disable this suffix. 52*7f2fe78bSCy Schubert 53*7f2fe78bSCy SchubertIf **dns_canonicalize_hostname** is set to ``fallback`` (added in 54*7f2fe78bSCy Schubertrelease 1.18), the hostname is initially treated according to the 55*7f2fe78bSCy Schubertrules for ``dns_canonicalize_hostname=false``. If a ticket request 56*7f2fe78bSCy Schubertfails because the service principal is unknown, the hostname will be 57*7f2fe78bSCy Schubertcanonicalized according to the rules for 58*7f2fe78bSCy Schubert``dns_canonicalize_hostname=true`` and the request will be retried. 59*7f2fe78bSCy Schubert 60*7f2fe78bSCy SchubertIn all cases, the hostname is converted to lowercase, and any trailing 61*7f2fe78bSCy Schubertdot is removed. 62*7f2fe78bSCy Schubert 63*7f2fe78bSCy Schubert 64*7f2fe78bSCy Schubert 65*7f2fe78bSCy SchubertReverse DNS mismatches 66*7f2fe78bSCy Schubert---------------------- 67*7f2fe78bSCy Schubert 68*7f2fe78bSCy SchubertSometimes, an enterprise will have control over its forward DNS but 69*7f2fe78bSCy Schubertnot its reverse DNS. The reverse DNS is sometimes under the control 70*7f2fe78bSCy Schubertof the Internet service provider of the enterprise, and the enterprise 71*7f2fe78bSCy Schubertmay not have much influence in setting up reverse DNS records for its 72*7f2fe78bSCy Schubertaddress space. If there are difficulties with getting forward and 73*7f2fe78bSCy Schubertreverse DNS to match, it is best to set ``rdns = false`` on client 74*7f2fe78bSCy Schubertmachines. 75*7f2fe78bSCy Schubert 76*7f2fe78bSCy Schubert 77*7f2fe78bSCy SchubertOverriding application behavior 78*7f2fe78bSCy Schubert------------------------------- 79*7f2fe78bSCy Schubert 80*7f2fe78bSCy SchubertApplications can choose to use a default hostname component in their 81*7f2fe78bSCy Schubertservice principal name when accepting authentication, which avoids 82*7f2fe78bSCy Schubertsome sorts of hostname mismatches. Because not all relevant 83*7f2fe78bSCy Schubertapplications do this yet, using the :ref:`krb5.conf(5)` setting:: 84*7f2fe78bSCy Schubert 85*7f2fe78bSCy Schubert [libdefaults] 86*7f2fe78bSCy Schubert ignore_acceptor_hostname = true 87*7f2fe78bSCy Schubert 88*7f2fe78bSCy Schubertwill allow the Kerberos library to override the application's choice 89*7f2fe78bSCy Schubertof service principal hostname and will allow a server program to 90*7f2fe78bSCy Schubertaccept incoming authentications using any key in its keytab that 91*7f2fe78bSCy Schubertmatches the service name and realm name (if given). This setting 92*7f2fe78bSCy Schubertdefaults to "false" and is available in releases krb5-1.10 and later. 93*7f2fe78bSCy Schubert 94*7f2fe78bSCy Schubert 95*7f2fe78bSCy SchubertProvisioning keytabs 96*7f2fe78bSCy Schubert-------------------- 97*7f2fe78bSCy Schubert 98*7f2fe78bSCy SchubertOne service principal entry that should be in the keytab is a 99*7f2fe78bSCy Schubertprincipal whose hostname component is the canonical hostname that 100*7f2fe78bSCy Schubert``getaddrinfo()`` reports for all known aliases for the host. If the 101*7f2fe78bSCy Schubertreverse DNS information does not match this canonical hostname, an 102*7f2fe78bSCy Schubertadditional service principal entry should be in the keytab for this 103*7f2fe78bSCy Schubertdifferent hostname. 104*7f2fe78bSCy Schubert 105*7f2fe78bSCy Schubert 106*7f2fe78bSCy SchubertSpecific application advice 107*7f2fe78bSCy Schubert--------------------------- 108*7f2fe78bSCy Schubert 109*7f2fe78bSCy SchubertSecure shell (ssh) 110*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~ 111*7f2fe78bSCy Schubert 112*7f2fe78bSCy SchubertSetting ``GSSAPIStrictAcceptorCheck = no`` in the configuration file 113*7f2fe78bSCy Schubertof modern versions of the openssh daemon will allow the daemon to try 114*7f2fe78bSCy Schubertany key in its keytab when accepting a connection, rather than looking 115*7f2fe78bSCy Schubertfor the keytab entry that matches the host's own idea of its name 116*7f2fe78bSCy Schubert(typically the name that ``gethostname()`` returns). This requires 117*7f2fe78bSCy Schubertkrb5-1.10 or later. 118*7f2fe78bSCy Schubert 119*7f2fe78bSCy SchubertOpenLDAP (ldapsearch, etc.) 120*7f2fe78bSCy Schubert~~~~~~~~~~~~~~~~~~~~~~~~~~~ 121*7f2fe78bSCy Schubert 122*7f2fe78bSCy SchubertOpenLDAP's SASL implementation performs reverse DNS lookup in order to 123*7f2fe78bSCy Schubertcanonicalize service principal names, even if **rdns** is set to 124*7f2fe78bSCy Schubert``false`` in the Kerberos configuration. To disable this behavior, 125*7f2fe78bSCy Schubertadd ``SASL_NOCANON on`` to ``ldap.conf``, or set the 126*7f2fe78bSCy Schubert``LDAPSASL_NOCANON`` environment variable. 127