Kerberos is a powerful set of programs which allow you to have encrypted connections to virtually anything: TELNET, FTP and even e-mail. This is of little use to the modem user, but in larger settings where Ethernet is used and sniffing is a real danger, Kerberos provides a viable and powerful solution. There is, however, one problem—Kerberos is notoriously known for being overly complex and difficult to install. This article is designed to help you make a good start; before you know it, with a little experimentation everything will (kind of) work. I wish I could explain everything in detail here, but then, this would be a book, not an article.
Like almost every major upgrade/change, it would be ideal to make a backup of your system. If you can, do it. If you don't have a tape drive be careful installing, Kereberos shouldn't write over your files, but if you want to be sure, make copies of /sbin somewhere. It takes two seconds and if something goes wrong it will be well worth your time.
Now we go grab the files. There are binary and source distributions of Kerberos for Linux. I've found that the source usually causes me less problems than the binaries. If you are up to playing around a bit go ahead and get the source, otherwise grab the binaries. Either can be found at http://web.mit.edu/kerberos/www/. I'll cover only the binaries here—simply because compiling the source isn't part of the scope of this article. I'm going to assume you managed to install things right. One important note: If you do choose to use the source (I recommend you do) make sure you extract all the tar archive files, not just the one containing the source. Also, if you install things in a different directory (not /krb5) then you will need to modify the files mentioned below to reflect your installation directory.
These two files control virtually everything. They control the name of your REALM (see below) and who can connect; however, they can be fairly complex. Before you set them up, you will probably need to understand a few terms:
REALM: I think of a realm as a “group”. Machines will belong to this group. It has become almost standard procedure to make the realm the same as your domain name, just with capital letters. In my case, I called it UNDER, but you could call it anything you wanted. Yes, you can have more than one REALM, but you probably won't need one. Remember—the REALM is case sensitive! Pick a standard and stick to it.
KEYTAB: a file that contains encrypted information allowing users/machines to authenticate themselves. Each machine that attempts to authenticate itself to the KDC (see below) must have one. This is done by issuing the ktadd command under kadmin.
KDC: the Kerberos Distribution Center—the one that causes you headaches. This is the machine that controls access.
PRINCIPAL: a principal is a “definition” of a user or a host. It is, effectively, what tells the server a user exists or a server is trusted.
INCIDENT: when making a new principal, the notation is as follows: incident/host@REALM. For example, with ktadd, doing something like
ktadd host/pepsi.kellogg.nwu.edu@UNDER
would make the incident host for the machine pepsi.kellogg.nwu.edu which is part of the UNDER realm.
Take a look at my /etc/krb5.conf file and notice the following:
default_realm = UNDER: name of your realm.
profile = /krb5/var/krb5kdc/kdc.conf: location of your kdc.conf file
Also note the section called [realms]. Under it, I have the name of my realm, UNDER, and the machine that hosts that information, in this case, underground.kellogg.nwu.edu. This will be the hostname of where you just installed Kerberos. [domain_realm] explains who can connect to the realm: anyone from anywhere within kellogg and within res-hall (the dorm rooms at Northwestern). Replace all the information mentioned above with the name of your REALM and the name of the machine you installed the server on.
Now on to your kdc.conf file. You are going to need to place it wherever you defined it in /etc/krb5.conf. My suggestion is you place it in the same directory I did. This will mean making these directories. If you do that, you can just copy my kdc.conf and save yourself some time. Just change the name of the realm to whatever you picked when making krb5.conf file. These two files are integral to making things work. You may want to double check for typos and possibly save yourself some headaches later.
Now, some tedious but easy work must be done. Create the database that controls who can login where by issuing the following command:
# kdb5_util create -r
Initializing database '/krb5/lvar/krb5kdc/principal' for
realm '
master key name 'K/M@YOUR_REALM'
In my case, YOUR_REALM would have been UNDER. Just replace it with whatever the host name of the machine you are on right now is. You will be asked for a master password; pick something you won't forget.
Now you must make an ACL file. This basically controls who can connect and administer the REALM. It can also be complex, but for our purposes we will keep it simple. Edit the file (or create) defined by acl = in the kdc.conf file. Place the following on a line by itself:
*/admin@
This means the administrator can control things. I don't see why you would want anything else anyway.
Now it is time to add users to the machine. First, start off with the administrator account.
# kadmin.local
kadmin.local: addprinc admin/admin@
Enter password for principal "admin/admin@
your_password
Re-enter password for principal "admin/admin@
your_password
Principal "admin/admin@YOUR_REALM" created.
Then create a keytab on the server. This will authenticate who can modify things on the server and who cannot. Make sure you place everything on one line (including kadmin/changepw):
kadmin.local: ktadd -k /etc/kadm5.keytab kadmin/admin kadmin/changepw Entry for principal kadmin/admin with kvno 3, encryption type DES-CBC-CRC added to keytab WRFILE:/etc/kadm5.keytab. Entry for principal kadmin/changepw with kvno 3, encryption type DES-CBC-CRC added to keytab WRFILE:/etc/kadm5.keytab.You should see something similar, but probably not identical. Then you have to add the necessary information to the server. Edit your /etc/inetd.conf and insert the following:
krb5_prop 754/tcp # Kerberos v5 slave propagation kerberos-adm 749/tcp # Kerberos v5 admin/chpwd kerberos-adm 749/udp # Kerberos v5 admin/chpwd kpasswd 761/tcp kpwd # Kerberos "passwd" -kfallNow, as root, restart inetd and run krb5kdc and kadmind. Congratulations, most of the pain is over. It took me eight hours to get here my first time trying this—hope you did better.
Now test it. A few commands to know about are kinit, klist and kdestory. These initialize your tickets which authorize you, list them and destroy them. (Yes, from the user's point of view, everything is fairly simple.) So try it out by doing a kinit admin/admin@YOUR_REALM
underground:~> kinit admin/admin Password for admin/admin@UNDER: underground:~> klist Ticket cache: /tmp/krb5cc_1000 Default principal: admin/admin@UNDER Valid starting Expires Service principal 08 May 98 15:04:45 09 May 98 01:04:43 krbtgt/UNDER@UNDER
If you got it to work this far, you are virtually done. Add yourself as a user. Run kadmin—it should ask you for a password, same as the one you typed in way back when you created kadmin/admin. The procedure for adding another user is just as simple. Each user is a “principal” (don't ask me where the name came from).
kadmin: addprinc
Enter password for principal "user@
Re-enter password for principal "user@
Principal "user@YOUR_REALM" created.
Should you make a mistake, just delete the principal like so:
kadmin: delprinc user@
Are you sure you want to delete the principal "user@
Principal "user@YOUR_REALM" deleted.
Now test this out the same way you did the administrator. You
should get a new ticket.
I still haven't explained how to use it, so here we go. In order for you to be able to use Kerberos encrypted services on a machine, it must satisfy the following:
It has a principal host/hostname@REALM on the server
It has the correct services set up.
It has a keytab file and has /etc/inetd.conf set up right.
The easiest way to try this out is to set up the server so that it will let you make encrypted connections, before you attempt to add other machines. The problem is that it is a bit different from setting up another machine. So we are going to say we want to have kerberized TELNET and FTP on the machine pepsi.kellogg.nwu.edu for this example. To do this, you need to satisfy the three requirements above.
Let's go over the first. You are going to need to install Kerberos on the machine you want to offer kerberized services on first. All this means is putting the binaries on the machine (in our example pepsi.kellogg.nwu.edu). So just go install the binaries. You can, if you want, just copy them over. Then copy your /etc/krb5.conf file from the KDC (server) and place it on the machine you are giving kerberized services (pepsi.kellogg.nwu.edu). From that machine, you must run kinit admin/admin. Then run kadmind from your machine (or in my case pepsi.kellogg.nwu.edu) and run the following commands:
kadmin: addprinc host/pepsi.kellogg.nwu.edu kadmin: addprinc telnet/pepsi.kellogg.nwu.edu kadmin: addprinc ftp/pepsi.kellogg.nwu.edu kadmin: ktadd host/pepsi.kellogg.nwu.edu telnet/pepsi.kellogg.nwu.edu ftp/pepsi.kellogg.nwu.edu
A quick explanation is in order. For each service you plan to offer that is kerberized, you must have a principal. Hence, the use of telnet and ftp with the addprinc command. Then you must make the keytab. That is done by issuing the ktadd command. All of this must be done on the machine, you are setting up to offer services (in this case pepsi.kellogg.nwu.edu).
Finally, edit your /etc/inetd.conf and add the following lines. You will want to comment out any previous definitions of telnet and ftp.
klogin stream tcp nowait root /krb5/sbin/klogind klogind -ki eklogin stream tcp nowait root /krb5/sbin/klogind klogind -eki kshell stream tcp nowait root /krb5/sbin/kshd kshd -ki telnet stream tcp nowait root /krb5/sbin/telnetd telnetd -a valid ftp stream tcp nowait root /krb5/sbin/ftpd -a
Go back to the main server and create yourself a ticket (kinit user@YOUR_REALM). Now make a user (see above addprinc command) for yourself and try to login using telnet like this:
underground:~> telnet -l cosimo pepsi Trying 129.105.197.33... Connected to pepsi.kellogg.nwu.edu (129.105.197.33). Escape character is '^]'. [ Kerberos V5 accepts you as "cosimo@UNDER" ] Last login: Fri May 8 13:44:44 on tty2 Linux 2.0.30. pepsi:~>Note how you didn't have to enter a password. That's okay, because the ticket gave you the access to the machine. The ticket does eventually expire, but it can be renewed by issuing a new kinit command. (Do a klist to see when it does expire. If you copied my /etc/krb5.conf, it will be 600 minutes.)
Let us tie up a few loose ends: you should be aware that changing telnetd -a valid to telnetd -a user will allow users to login without authentication. If they don't run kinit, they won't even get a login prompt if you use telnet -a valid. Remember, since the passwords are stored on your KDC, make sure no one breaks into it; otherwise, they will have access to all the machines to which the KDC grants access. Get to know the terms principal, realm, kdc, etc.—almost anything you come across will use them.