How to create a Kerberos realm for single sign-on running on NetBSD
You want to organize your users and services into a Kerberos realm to enable single sign-on to your web sites and other services at hostnames under example.com. How do you set it up?
Pick a realm name. This is normally the uppercase version of your organization's domain name in the DNS, EXAMPLE.COM.
Note: Unlike DNS domain names, Kerberos realm names are case-sensitive.
Pick a host to run the Kerberos Key Distribution Center, say kdc.example.com.
Make sure TCP traffic on port 88 to kdc.example.com goes to the host, in case it is behind a NAT or firewall or similar.
Optional: Create DNS records in the example.com. zone, to make it easier for users:
For access to services under
example.com, clients will consult_kerberos.example.comTXT records to find the realm name—seedns_lookup_realmin krb5.conf(5).To find the KDC for the realm EXAMPLE.COM, clients and services will consult
_kerberos._tcp.example.comSRV records—seedns_lookup_kdcin krb5.conf(5).If you don't set this up, you will need to distribute krb5.conf(5) files to all users with the realm name and domain-to-realm mapping; see the
[domain_realm]and[realms]sections in the krb5.conf(5) man page for details.On kdc.example.com, create /etc/krb5.conf with the following content:
Check it by running:
# verify_krb5_conf /etc/krb5.conf
Initialize the KDC:
# kadmin -l init EXAMPLE.COM Realm max ticket life [unlimited]: Realm max renewable ticket life [unlimited]:
Hit return when prompted to use the defaults.
This will create the database at the default location under
/var/heimdal.Create a user principal and an admin principal. We'll call the user
jruserfor J. Random User.# kadmin -l add --use-defaults jruser jruser@EXAMPLE.COM's Password: Verifying - jruser@EXAMPLE.COM's Password: # kadmin -l add --use-defaults jruser/admin jruser/admin@EXAMPLE.COM's Password: Verifying - jruser/admin@EXAMPLE.COM's Password:
The admin principal
jruser/admin@EXAMPLE.COMis used by kadmin(8) for remote access via kadmind(8). It need not have the same password asjruser@EXAMPLE.COM.Start up
kdc, the KDC daemon. Enable it in /etc/rc.conf:Then either reboot or start it explicitly:
# service kdc start
Enable kadmind(8) for remote admin access, and kpasswdd(8) for remote password changes.
Extract keys into the keytab at /etc/krb5.keytab for kadmind(8) and kpasswdd(8):
# kadmin -l ext kadmin/admin@EXAMPLE.COM # kadmin -l ext kadmin/changepw@EXAMPLE.COM
Create an access control list for admins:
Add entries to /etc/inetd.conf for the services:
Reboot or tell inetd(8) to reload /etc/inetd.conf:
# service inetd reload
Now you can do kinit jruser@EXAMPLE.COM for
client-side single sign-on, use
kpasswd(1) to change your password
or kpasswd(8) administer the
realm, and set up kerberized services!
