Mr. Leipold explains what Kerberos is and why you want it.
by Cosimo Leipold
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:
ktadd host/pepsi.kellogg.nwu.edu@UNDER
Take a look at my /etc/krb5.conf file and notice the following:
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@UNDERIf 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:
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.eduA 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 -aGo 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.
Well, you most likely feel I've left out a lot--and you are right, I have. There is plenty more to learn and plenty more to try. The MIT webpage has tons of links to more information. Of course, you can always e-mail me and ask me, and I'll try to answer you quickly.
Cosimo Leipold (cleipold@kellogg.nwu.edu) is a student at Northwestern University who has nothing better to do than learn UNIX. He now works for the Kellogg Graduate School of Management as a System Administrator. He lives with his love Chiara, who says he's a dork.