Difference between revisions of "MIT krb5"

From CBLFS
Jump to navigationJump to search
(I added the MIT krb5 instructions from BLFS (no multilib instructions added).)
 
 
(42 intermediate revisions by 5 users not shown)
Line 2: Line 2:
 
|-valign="top"
 
|-valign="top"
 
! Download Source:
 
! Download Source:
| http://web.mit.edu/kerberos/www/dist/krb5/1.4/krb5-1.4.1-signed.tar
+
| http://web.mit.edu/kerberos/www/dist/krb5/{{MIT_krb5-Version}}/krb5-{{MIT_krb5-Version2}}-signed.tar
 
|}
 
|}
  
 
----
 
----
  
== Introduction to MIT Krb5 ==
+
{{Package-Introduction|Kerberos is a network authentication protocol. It is designed to provide strong authentication for client/server applications by using secret-key cryptography. A free implementation of this protocol is available from the Massachusetts Institute of Technology.|http://web.mit.edu/Kerberos/}}
  
MIT krb5 is a free implementation of Kerberos 5. Kerberos is a network authentication protocol. It centralizes the authentication database and uses kerberized applications to work with servers or services that support Kerberos allowing single logins and encrypted communication over internal networks or the Internet.
+
== Dependencies ==
  
== Dependencies ==
+
=== !!!HIGHLY RECOMMENDED!!! ===
 +
* [[NTP]]
  
 
=== Optional ===
 
=== Optional ===
 
* [[xinetd]] (services servers only)
 
* [[xinetd]] (services servers only)
* [[Linux-Pam]] (for '''xdm''' based logins)
+
* [[Linux-PAM]] (for '''xdm''' based logins)
 
* [[OpenLDAP]] (alternative for '''krb5kdc''' password database)
 
* [[OpenLDAP]] (alternative for '''krb5kdc''' password database)
  
'''Note:'''
+
{{Note|A time synchronization facility of some sort (like [[NTP]]) is needed on your system if you're going to be using Kerberos. Kerberos won't authenticate if the time differential between a kerberized client and the KDC server is more than 5 minutes. And since you'll probably want Kerberos to be able to authenticate, you'll want to synchronize the time between teh client and the server.}}
Some sort of time synchronization facility on your system (like [[NTP]])
 
is required since Kerberos won't authenticate if the time differential
 
between a kerberized client and the KDC server is more than 5 minutes.
 
  
 
== Non-Multilib ==
 
== Non-Multilib ==
  
MIT krb5 is distributed in a TAR file containing a compressed TAR package and a detached PGP ASC file.
+
Build the packge:
  
If you have installed [[GnuPG]], you can authenticate the package with the following command:
+
cd src &&  CPPFLAGS="-DEAI_NODATA=EAI_NONAME" \
 +
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
 +
    --enable-dns-for-realm --mandir=/usr/share/man &&
 +
make
  
gpg - -verify krb5-1.4.1.tar.gz.asc
+
Install the package:
  
Build MIT krb5 by running the following commands:
+
make install &&
 +
chmod -v 755 /usr/lib/lib{krb5support,com_err,k5crypto,krb5}.so* &&
 +
chmod -v 755 /usr/lib/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
 +
chmod -v 755 /usr/lib/krb5/plugins/*/*.so &&
 +
mv -v /usr/lib/libcom_err.so.3* /lib &&
 +
mv -v /usr/lib/libgssapi_krb5.so.2* /lib &&
 +
mv -v /usr/lib/libgssrpc.so.4* /lib &&
 +
mv -v /usr/lib/libk5crypto.so.3* /lib &&
 +
mv -v /usr/lib/libkadm5clnt.so.6* /lib &&
 +
mv -v /usr/lib/libkadm5srv.so.6* /lib &&
 +
mv -v /usr/lib/libkdb5.so.4* /lib &&
 +
mv -v /usr/lib/libkrb5.so.3* /lib &&
 +
mv -v /usr/lib/libkrb5support.so.0* /lib &&
 +
ln -v -sf ../../lib/libcom_err.so.3 /usr/lib/libcom_err.so &&
 +
ln -v -sf ../../lib/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so &&
 +
ln -v -sf ../../lib/libgssrpc.so.4 /usr/lib/libgssrpc.so &&
 +
ln -v -sf ../../lib/libk5crypto.so.3 /usr/lib/libk5crypto.so &&
 +
ln -v -sf ../../lib/libkadm5clnt.so.6 /usr/lib/libkadm5clnt.so &&
 +
ln -v -sf ../../lib/libkadm5srv.so.6 /usr/lib/libkadm5srv.so &&
 +
ln -v -sf ../../lib/libkdb5.so.4 /usr/lib/libkdb5.so &&
 +
ln -v -sf ../../lib/libkrb5.so.3 /usr/lib/libkrb5.so &&
 +
ln -v -sf ../../lib/libkrb5support.so.0 /usr/lib/libkrb5support.so &&
 +
mv -v /usr/bin/ksu /bin &&
 +
ldconfig
 +
 
 +
== Multilib ==
 +
 
 +
=== 32Bit ===
 +
 
 +
Build the packge:
  
 
  cd src &&
 
  cd src &&
  ./configure --prefix=/usr --sysconfdir=/etc \
+
CPPFLAGS="-DEAI_NODATA=EAI_NONAME" CC="gcc ${BUILD32}" USE_ARCH=32 \
    --localstatedir=/var/lib --enable-dns \
+
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
    --enable-static --mandir=/usr/share/man &&
+
    --enable-dns-for-realm --mandir=/usr/share/man &&
 
  make
 
  make
  
Line 42: Line 72:
  
 
  make install &&
 
  make install &&
  mv -v /usr/bin/ksu /bin &&
+
chmod -v 755 /usr/lib/lib{krb5support,com_err,k5crypto,krb5}.so* &&
 +
chmod -v 755 /usr/lib/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
 +
chmod -v 755 /usr/lib/krb5/plugins/*/*.so &&
 +
mv -v /usr/lib/libcom_err.so.3* /lib &&
 +
mv -v /usr/lib/libgssapi_krb5.so.2* /lib &&
 +
mv -v /usr/lib/libgssrpc.so.4* /lib &&
 +
mv -v /usr/lib/libk5crypto.so.3* /lib &&
 +
mv -v /usr/lib/libkadm5clnt.so.6* /lib &&
 +
mv -v /usr/lib/libkadm5srv.so.6* /lib &&
 +
  mv -v /usr/lib/libkdb5.so.4* /lib &&
 
  mv -v /usr/lib/libkrb5.so.3* /lib &&
 
  mv -v /usr/lib/libkrb5.so.3* /lib &&
  mv -v /usr/lib/libkrb4.so.2* /lib &&
+
  mv -v /usr/lib/libkrb5support.so.0* /lib &&
  mv -v /usr/lib/libdes425.so.3* /lib &&
+
  ln -v -sf ../../lib/libcom_err.so.3 /usr/lib/libcom_err.so &&
  mv -v /usr/lib/libk5crypto.so.3* /lib &&
+
ln -v -sf ../../lib/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so &&
  mv -v /usr/lib/libcom_err.so.3* /lib &&
+
  ln -v -sf ../../lib/libgssrpc.so.4 /usr/lib/libgssrpc.so &&
 +
ln -v -sf ../../lib/libk5crypto.so.3 /usr/lib/libk5crypto.so &&
 +
  ln -v -sf ../../lib/libkadm5clnt.so.6 /usr/lib/libkadm5clnt.so &&
 +
ln -v -sf ../../lib/libkadm5srv.so.6 /usr/lib/libkadm5srv.so &&
 +
ln -v -sf ../../lib/libkdb5.so.4 /usr/lib/libkdb5.so &&
 
  ln -v -sf ../../lib/libkrb5.so.3 /usr/lib/libkrb5.so &&
 
  ln -v -sf ../../lib/libkrb5.so.3 /usr/lib/libkrb5.so &&
  ln -v -sf ../../lib/libkrb4.so.2 /usr/lib/libkrb4.so &&
+
  ln -v -sf ../../lib/libkrb5support.so.0 /usr/lib/libkrb5support.so &&
  ln -v -sf ../../lib/libdes425.so.3 /usr/lib/libdes425.so &&
+
  mv -v /usr/bin/ksu /bin &&
  ln -v -sf ../../lib/libk5crypto.so.3 /usr/lib/libk5crypto.so &&
+
  mv -v /usr/bin/krb5-config{,-32} &&
ln -v -sf ../../lib/libcom_err.so.3 /usr/lib/libcom_err.so &&
 
 
  ldconfig
 
  ldconfig
  
<font color=red>'''Warning:'''</font>
+
=== N32 ===
'''login.krb5''' does not support shadow passwords. As a result, when the Kerberos
 
server is unavailable, the default fall through to '''/etc/password''' will not work
 
because the passwords have been moved to '''/etc/shadow''' during the CLFS build
 
process. Entering the following commands without moving the passwords back
 
to '''/etc/password''' could prevent any logins.
 
  
If Linux-Pam is not installed and you understand the above warning, the following can be entered:
+
Build the packge:
  
  mv -v /bin/login /bin/login.shadow &&
+
  cd src &&
cp -v /usr/sbin/login.krb5 /bin/login
+
CPPFLAGS="-DEAI_NODATA=EAI_NONAME" CC="gcc ${BUILDN32}" USE_ARCH=n32 \
 +
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
 +
    --enable-dns-for-realm --mandir=/usr/share/man --libdir=/usr/lib32 &&
 +
make
  
If CrackLib is installed, or if any word list has been put in /usr/share/dict, the following should be entered:
+
Install the package:
  
  ln -s /usr/share/dict/words /var/lib/krb5kdc/kadmin.dict
+
make install &&
 +
chmod -v 755 /usr/lib32/lib{krb5support,com_err,k5crypto,krb5}.so* &&
 +
chmod -v 755 /usr/lib32/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
 +
chmod -v 755 /usr/lib32/krb5/plugins/*/*.so &&
 +
mv -v /usr/lib32/libcom_err.so.3* /lib32 &&
 +
mv -v /usr/lib32/libgssapi_krb5.so.2* /lib32 &&
 +
mv -v /usr/lib32/libgssrpc.so.4* /lib32 &&
 +
mv -v /usr/lib32/libk5crypto.so.3* /lib32 &&
 +
mv -v /usr/lib32/libkadm5clnt.so.6* /lib32 &&
 +
mv -v /usr/lib32/libkadm5srv.so.6* /lib32 &&
 +
mv -v /usr/lib32/libkdb5.so.4* /lib32 &&
 +
mv -v /usr/lib32/libkrb5.so.3* /lib32 &&
 +
mv -v /usr/lib32/libkrb5support.so.0* /lib32 &&
 +
ln -v -sf ../../lib32/libcom_err.so.3 /usr/lib32/libcom_err.so &&
 +
ln -v -sf ../../lib32/libgssapi_krb5.so.2 /usr/lib32/libgssapi_krb5.so &&
 +
  ln -v -sf ../../lib32/libgssrpc.so.4 /usr/lib32/libgssrpc.so &&
 +
ln -v -sf ../../lib32/libk5crypto.so.3 /usr/lib32/libk5crypto.so &&
 +
ln -v -sf ../../lib32/libkadm5clnt.so.6 /usr/lib32/libkadm5clnt.so &&
 +
ln -v -sf ../../lib32/libkadm5srv.so.6 /usr/lib32/libkadm5srv.so &&
 +
ln -v -sf ../../lib32/libkdb5.so.4 /usr/lib32/libkdb5.so &&
 +
ln -v -sf ../../lib32/libkrb5.so.3 /usr/lib32/libkrb5.so &&
 +
ln -v -sf ../../lib32/libkrb5support.so.0 /usr/lib32/libkrb5support.so &&
 +
mv -v /usr/bin/ksu /bin &&
 +
mv -v /usr/bin/krb5-config{,-n32} &&
 +
ldconfig
  
=== Command Explanations ===
+
=== 64Bit ===
  
--enable-dns: This switch allows realms to be resolved using the DNS server.
+
Build the packge:
  
--enable-static: This switch builds static libraries in addition to the shared libraries.
+
cd src &&
 +
CPPFLAGS="-DEAI_NODATA=EAI_NONAME" CC="gcc ${BUILD64}" USE_ARCH=64 \
 +
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
 +
    --enable-dns-for-realm --mandir=/usr/share/man --libdir=/usr/lib64 &&
 +
make
  
'''mv -v /bin/login /bin/login.shadow && cp -v /usr/sbin/login.krb5 /bin/login && mv -v /usr/bin/ksu /bin''': Preserves Shadow's '''login''' command, moves '''ksu''' and '''login''' to the /bin directory.
+
Install the package:
  
'''mv -v ... /lib && ln -v -sf ...''': The '''login''' and '''ksu''' programs are linked against these libraries, therefore these libraries are moved to /lib to allow logins without mounting /usr.
+
make install &&
 +
chmod -v 755 /usr/lib64/lib{krb5support,com_err,k5crypto,krb5}.so* &&
 +
chmod -v 755 /usr/lib64/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
 +
chmod -v 755 /usr/lib64/krb5/plugins/*/*.so &&
 +
mv -v /usr/lib64/libcom_err.so.3* /lib64 &&
 +
mv -v /usr/lib64/libgssapi_krb5.so.2* /lib64 &&
 +
mv -v /usr/lib64/libgssrpc.so.4* /lib64 &&
 +
mv -v /usr/lib64/libk5crypto.so.3* /lib64 &&
 +
mv -v /usr/lib64/libkadm5clnt.so.6* /lib64 &&
 +
mv -v /usr/lib64/libkadm5srv.so.6* /lib64 &&
 +
mv -v /usr/lib64/libkdb5.so.4* /lib64 &&
 +
mv -v /usr/lib64/libkrb5.so.3* /lib64 &&
 +
mv -v /usr/lib64/libkrb5support.so.0* /lib64 &&
 +
ln -v -sf ../../lib64/libcom_err.so.3 /usr/lib64/libcom_err.so &&
 +
ln -v -sf ../../lib64/libgssapi_krb5.so.2 /usr/lib64/libgssapi_krb5.so &&
 +
ln -v -sf ../../lib64/libgssrpc.so.4 /usr/lib64/libgssrpc.so &&
 +
ln -v -sf ../../lib64/libk5crypto.so.3 /usr/lib64/libk5crypto.so &&
 +
ln -v -sf ../../lib64/libkadm5clnt.so.6 /usr/lib64/libkadm5clnt.so &&
 +
ln -v -sf ../../lib64/libkadm5srv.so.6 /usr/lib64/libkadm5srv.so &&
 +
ln -v -sf ../../lib64/libkdb5.so.4 /usr/lib64/libkdb5.so &&
 +
ln -v -sf ../../lib64/libkrb5.so.3 /usr/lib64/libkrb5.so &&
 +
ln -v -sf ../../lib64/libkrb5support.so.0 /usr/lib64/libkrb5support.so &&
 +
mv -v /usr/bin/ksu /bin &&
 +
mv -v /usr/bin/krb5-config{,-64} &&
 +
ln -sfv multiarch_wrapper /usr/bin/krb5-config &&
 +
ldconfig
  
== Multilib ==
+
== Configuring ==
  
=== 32Bit ===
+
{{Note|'''login.krb5''' does not support shadow passwords. So, when the Kerberos server is unavailable, the default use of '''/etc/passwd''' will not work because the passwords are now in '''/etc/shadow''' (where they were put while building CLFS). Entering the following commands without moving the passwords back to '''/etc/passwd''' could prevent any logins.}}
  
TODO....
+
If you have [[Linux-PAM]] installed then you can authenticate using the login provided by shadow through the [[Pam-krb5]] module (Recommended). If you understand the above warning and [[Linux-PAM]] is not installed, the following commands can be used:
  
=== N32 ===
+
mv -v /bin/login /bin/login.shadow &&
 +
cp -v /usr/sbin/login.krb5 /bin/login
  
TODO....
+
The information in the sections below are based off information from the following pages:
  
=== 64Bit ===
+
http://www.bayour.com/LDAPv3-HOWTO.html
 +
http://aput.net/~jheiss/krbldap/
  
TODO....
+
=== Creating a Kerberos Realm ===
  
== Configuring ==
+
{{Note|At this point it is strongly recommended that you have a working DNS Server. After setting up a login with Kerberos failure to resolve the name of the KDC server will result in login failures.}}
  
=== Configuration Files ===
+
Create the db directory exists with the following command:
  
/etc/krb5.conf and /var/lib/krb5kdc/kdc.conf
+
install -dv -m755 /var/lib/krb5kdc
  
=== Kerberos Configuration ===
+
Create the Kerberos configuration with the following command. It's recommended that the Kerberos Realm be all uppercase.
  
Create the Kerberos configuration file with the following command:
 
 
<pre>
 
 
  cat > /etc/krb5.conf << "EOF"
 
  cat > /etc/krb5.conf << "EOF"
 
  # Begin /etc/krb5.conf
 
  # Begin /etc/krb5.conf
 
   
 
   
 
  [libdefaults]
 
  [libdefaults]
     default_realm = <LFS.ORG>
+
     default_realm = ''<REALMNAME.COM>''
 
     encrypt = true
 
     encrypt = true
 +
 +
[kdc]
 +
    profile = /var/lib/krb5kdc/kdc.conf
 +
 +
[appdefaults]
 +
    pam = {
 +
        ''<REALMNAME.COM>'' = {
 +
            minimum_uid = 5000
 +
        }
 +
    }
 
   
 
   
 
  [realms]
 
  [realms]
     <LFS.ORG> = {
+
     ''<REALMNAME.COM>'' = {
         kdc = <belgarath.lfs.org>
+
         kdc = ''<servername.realmname.com>''
         admin_server = <belgarath.lfs.org>
+
         admin_server = ''<servername.realmname.com>''
 +
        dict_file = /usr/share/dict/words
 
     }
 
     }
 
   
 
   
 
  [domain_realm]
 
  [domain_realm]
     .<lfs.org> = <LFS.ORG>
+
     .''<realmname.com>'' = ''<REALMNAME.COM>''
 +
    ''<realmname.com>'' = ''<REALMNAME.COM>''
 
   
 
   
 
  [logging]
 
  [logging]
    kdc = SYSLOG[:INFO[:AUTH]]
+
<nowiki>    kdc = SYSLOG[:INFO[:AUTH]]</nowiki>
    admin_server = SYSLOG[INFO[:AUTH]]
+
<nowiki>    admin_server = SYSLOG[INFO[:AUTH]]</nowiki>
    default = SYSLOG[[:SYS]]
+
<nowiki>    default = SYSLOG[[:SYS]]</nowiki>
 
   
 
   
 
  # End /etc/krb5.conf
 
  # End /etc/krb5.conf
 
  EOF
 
  EOF
</pre>
 
  
You will need to substitute your domain and proper hostname for the occurences of the <belgarath> and <lfs.org> names.
+
On the Kerberos Server create the KDC Configuration File:
  
default_realm should be the name of your domain changed to ALL CAPS. This isn't required, but both Heimdal and MIT recommend it.
+
cat > /var/lib/krb5kdc/kdc.conf << "EOF"
 +
# Begin /var/lib/krb5kdc/kdc.conf
 +
 +
[kdcdefaults]
 +
    kdc_ports = 750,88
 +
 +
[realms]
 +
    ''<REALMNAME.COM>'' = {
 +
        database_name = /var/lib/krb5kdc/principal
 +
        admin_keytab = FILE:/var/lib/krb5kdc/kadm5.keytab
 +
        acl_file = /var/lib/krb5kdc/krb5_adm.acl
 +
        key_stash_file = /var/lib/krb5kdc/.k5.''<REALMNAME.COM>''
 +
        kdc_ports = 750,88
 +
        max_life = 10h 0m 0s
 +
        max_renewable_life = 7d 0h 0m 0s
 +
    }
 +
 +
# End /var/lib/krb5kdc/kdc.conf
 +
EOF
  
encrypt = true provides encryption of all traffic between kerberized clients and servers. It's not necessary and can be left off. If you leave it off, you can encrypt all traffic from the client to the server using a switch on the client program instead.
+
Execute the following command to initialize the Krb5 database:
  
The [realms] parameters tell the client programs where to look for the KDC authentication services.
+
kdb5_util create -r ''REALMNAME.COM'' -s
  
The [domain_realm] section maps a domain to a realm.
+
Create the Admin Service Keytab:
  
Create the KDC database:
+
kadmin.local -q "ktadd -k /var/lib/krb5kdc/kadm5.keytab kadmin/admin" &&
 +
kadmin.local -q "ktadd -k /var/lib/krb5kdc/kadm5.keytab kadmin/changepw" &&
 +
chmod 600 /var/lib/krb5kdc/kadm5.keytab
  
kdb5_util create -r <LFS.ORG> -s
+
Create a user to administer Kerberos with:
  
Now you should populate the database with principles (users). For now, just use your regular login name or root.
+
kadmin.local -q "addprinc krbadm@''<REALMNAME.COM>''"
 +
kadmin.local -q "addprinc krbadm/admin@''<REALMNAME.COM>''"
  
kadmin.local
+
Create a basic acl file:
kadmin: add_policy dict-only
 
kadmin: addprinc -policy dict-only <loginname>
 
  
The KDC server and any machine running kerberized server daemons must have a host key installed:
+
cat > /var/lib/krb5kdc/krb5_adm.acl << "EOF"
 +
kadmin/admin@''<REALMNAME.COM>''  *
 +
*/admin@''<REALMNAME.COM>''        *
 +
krbadm@''<REALMNAME.COM>''        *
 +
*/*@''<REALMNAME.COM>''            i
 +
EOF
  
kadmin: addprinc -randkey host/<belgarath.lfs.org>
+
=== Testing ===
  
After choosing the defaults when prompted, you will have to export the data to a keytab file:
+
Start the kdc service with the following command:
 
 
kadmin: ktadd host/<belgarath.lfs.org>
 
 
 
This should have created a file in /etc named krb5.keytab (Kerberos 5). This file should have 600 (root rw only) permissions. Keeping the keytab files from public access is crucial to the overall security of the Kerberos installation.
 
 
 
Eventually, you'll want to add server daemon principles to the database and extract them to the keytab file. You do this in the same way you created the host principles. Below is an example:
 
 
 
kadmin: addprinc -randkey ftp/<belgarath.lfs.org>
 
kadmin: ktadd ftp/<belgarath.lfs.org>
 
 
 
Exit the '''kadmin''' program (use '''quit''' or '''exit''') and return back to the shell prompt. Start the KDC daemon manually, just to test out the installation:
 
  
 
  /usr/sbin/krb5kdc &
 
  /usr/sbin/krb5kdc &
  
Attempt to get a ticket with the following command:
+
The following command will simulate a login:
  
  kinit <loginname>
+
  kinit ''<principle name>''
  
You will be prompted for the password you created. After you get your ticket, you can list it with the following command:
+
To list your current tickets:
  
 
  klist
 
  klist
  
Information about the ticket should be displayed on the screen.
+
=== Bootscript ===
  
To test the functionality of the keytab file, issue the following command:
+
Install the init script included in the [[bootscripts]] package.
 
 
ktutil
 
ktutil: rkt /etc/krb5.keytab
 
ktutil: l
 
 
 
This should dump a list of the host principal, along with the encryption methods used to access the principal.
 
 
 
At this point, if everything has been successful so far, you can feel fairly confident in the installation and configuration of the package.
 
 
 
Install the /etc/rc.d/init.d/kerberos init script included in the [http://www.linuxfromscratch.org/blfs/view/svn/introduction/bootscripts.html blfs-bootscripts] package.
 
  
 
  make install-kerberos
 
  make install-kerberos
  
=== Using Kerberized Client Programs ===
+
=== Configuring Kerberos Clients ===
  
To use the kerberized client programs ('''telnet''', '''ftp''', '''rsh''', '''rcp''', '''rlogin'''), you first must get an authentication ticket. Use the '''kinit''' program to get the ticket. After you've acquired the ticket, you can use the kerberized programs to connect to any kerberized server on the network. You will not be prompted for authentication until your ticket expires (default is one day), unless you specify a different user as a command line argument to the program.
+
Securly copy '''/etc/krb5.conf''' from one of the Kerberos Servers to each of the clients. You should now be able to get a ticket from the KDC. Now would be a good time to test this:
  
The kerberized programs will connect to non kerberized daemons, warning you that authentication is not encrypted.
+
kinit ''<principal name>''
  
=== Using Kerberized Server Programs ===
+
List your tickets with the following command:
  
Using kerberized server programs ('''telnetd''', '''kpropd''', '''klogind''' and '''kshd''') requires two additional configuration steps. First the /etc/services file must be updated to include eklogin and krb5_prop. Second, the inetd.conf or xinetd.conf must be modified for each server that will be activated, usually replacing the server from [[Inetutils]].
+
klist
 
 
=== Additional Information ===
 
 
 
For additional information consult [http://web.mit.edu/kerberos/www/krb5-1.4/#documentation Documentation for krb-1.4.1] on which the above instructions are based.
 
  
 
= Contents =
 
= Contents =
Line 322: Line 424:
 
| is an all-purpose Kerberos 5 library.  
 
| is an all-purpose Kerberos 5 library.  
 
|}
 
|}
 +
 +
[[Category:General Libs]]

Latest revision as of 10:36, 20 September 2009

Download Source: http://web.mit.edu/kerberos/www/dist/krb5/1.7/krb5-1.7-signed.tar

Introduction to MIT krb5

Kerberos is a network authentication protocol. It is designed to provide strong authentication for client/server applications by using secret-key cryptography. A free implementation of this protocol is available from the Massachusetts Institute of Technology.

Project Homepage: http://web.mit.edu/Kerberos/

Dependencies

!!!HIGHLY RECOMMENDED!!!

Optional

  • xinetd (services servers only)
  • Linux-PAM (for xdm based logins)
  • OpenLDAP (alternative for krb5kdc password database)
Caution.png

Note

A time synchronization facility of some sort (like NTP) is needed on your system if you're going to be using Kerberos. Kerberos won't authenticate if the time differential between a kerberized client and the KDC server is more than 5 minutes. And since you'll probably want Kerberos to be able to authenticate, you'll want to synchronize the time between teh client and the server.

Non-Multilib

Build the packge:

cd src &&  CPPFLAGS="-DEAI_NODATA=EAI_NONAME" \
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
   --enable-dns-for-realm --mandir=/usr/share/man &&
make

Install the package:

make install &&
chmod -v 755 /usr/lib/lib{krb5support,com_err,k5crypto,krb5}.so* &&
chmod -v 755 /usr/lib/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
chmod -v 755 /usr/lib/krb5/plugins/*/*.so &&
mv -v /usr/lib/libcom_err.so.3* /lib &&
mv -v /usr/lib/libgssapi_krb5.so.2* /lib &&
mv -v /usr/lib/libgssrpc.so.4* /lib &&
mv -v /usr/lib/libk5crypto.so.3* /lib &&
mv -v /usr/lib/libkadm5clnt.so.6* /lib &&
mv -v /usr/lib/libkadm5srv.so.6* /lib &&
mv -v /usr/lib/libkdb5.so.4* /lib &&
mv -v /usr/lib/libkrb5.so.3* /lib &&
mv -v /usr/lib/libkrb5support.so.0* /lib &&
ln -v -sf ../../lib/libcom_err.so.3 /usr/lib/libcom_err.so &&
ln -v -sf ../../lib/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so &&
ln -v -sf ../../lib/libgssrpc.so.4 /usr/lib/libgssrpc.so &&
ln -v -sf ../../lib/libk5crypto.so.3 /usr/lib/libk5crypto.so &&
ln -v -sf ../../lib/libkadm5clnt.so.6 /usr/lib/libkadm5clnt.so &&
ln -v -sf ../../lib/libkadm5srv.so.6 /usr/lib/libkadm5srv.so &&
ln -v -sf ../../lib/libkdb5.so.4 /usr/lib/libkdb5.so &&
ln -v -sf ../../lib/libkrb5.so.3 /usr/lib/libkrb5.so &&
ln -v -sf ../../lib/libkrb5support.so.0 /usr/lib/libkrb5support.so &&
mv -v /usr/bin/ksu /bin &&
ldconfig

Multilib

32Bit

Build the packge:

cd src &&
CPPFLAGS="-DEAI_NODATA=EAI_NONAME" CC="gcc ${BUILD32}" USE_ARCH=32 \
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
   --enable-dns-for-realm --mandir=/usr/share/man &&
make

Install the package:

make install &&
chmod -v 755 /usr/lib/lib{krb5support,com_err,k5crypto,krb5}.so* &&
chmod -v 755 /usr/lib/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
chmod -v 755 /usr/lib/krb5/plugins/*/*.so &&
mv -v /usr/lib/libcom_err.so.3* /lib &&
mv -v /usr/lib/libgssapi_krb5.so.2* /lib &&
mv -v /usr/lib/libgssrpc.so.4* /lib &&
mv -v /usr/lib/libk5crypto.so.3* /lib &&
mv -v /usr/lib/libkadm5clnt.so.6* /lib &&
mv -v /usr/lib/libkadm5srv.so.6* /lib &&
mv -v /usr/lib/libkdb5.so.4* /lib &&
mv -v /usr/lib/libkrb5.so.3* /lib &&
mv -v /usr/lib/libkrb5support.so.0* /lib &&
ln -v -sf ../../lib/libcom_err.so.3 /usr/lib/libcom_err.so &&
ln -v -sf ../../lib/libgssapi_krb5.so.2 /usr/lib/libgssapi_krb5.so &&
ln -v -sf ../../lib/libgssrpc.so.4 /usr/lib/libgssrpc.so &&
ln -v -sf ../../lib/libk5crypto.so.3 /usr/lib/libk5crypto.so &&
ln -v -sf ../../lib/libkadm5clnt.so.6 /usr/lib/libkadm5clnt.so &&
ln -v -sf ../../lib/libkadm5srv.so.6 /usr/lib/libkadm5srv.so &&
ln -v -sf ../../lib/libkdb5.so.4 /usr/lib/libkdb5.so &&
ln -v -sf ../../lib/libkrb5.so.3 /usr/lib/libkrb5.so &&
ln -v -sf ../../lib/libkrb5support.so.0 /usr/lib/libkrb5support.so &&
mv -v /usr/bin/ksu /bin &&
mv -v /usr/bin/krb5-config{,-32} &&
ldconfig

N32

Build the packge:

cd src &&
CPPFLAGS="-DEAI_NODATA=EAI_NONAME" CC="gcc ${BUILDN32}" USE_ARCH=n32 \
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
   --enable-dns-for-realm --mandir=/usr/share/man --libdir=/usr/lib32 &&
make

Install the package:

make install &&
chmod -v 755 /usr/lib32/lib{krb5support,com_err,k5crypto,krb5}.so* &&
chmod -v 755 /usr/lib32/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
chmod -v 755 /usr/lib32/krb5/plugins/*/*.so &&
mv -v /usr/lib32/libcom_err.so.3* /lib32 &&
mv -v /usr/lib32/libgssapi_krb5.so.2* /lib32 &&
mv -v /usr/lib32/libgssrpc.so.4* /lib32 &&
mv -v /usr/lib32/libk5crypto.so.3* /lib32 &&
mv -v /usr/lib32/libkadm5clnt.so.6* /lib32 &&
mv -v /usr/lib32/libkadm5srv.so.6* /lib32 &&
mv -v /usr/lib32/libkdb5.so.4* /lib32 &&
mv -v /usr/lib32/libkrb5.so.3* /lib32 &&
mv -v /usr/lib32/libkrb5support.so.0* /lib32 &&
ln -v -sf ../../lib32/libcom_err.so.3 /usr/lib32/libcom_err.so &&
ln -v -sf ../../lib32/libgssapi_krb5.so.2 /usr/lib32/libgssapi_krb5.so &&
ln -v -sf ../../lib32/libgssrpc.so.4 /usr/lib32/libgssrpc.so &&
ln -v -sf ../../lib32/libk5crypto.so.3 /usr/lib32/libk5crypto.so &&
ln -v -sf ../../lib32/libkadm5clnt.so.6 /usr/lib32/libkadm5clnt.so &&
ln -v -sf ../../lib32/libkadm5srv.so.6 /usr/lib32/libkadm5srv.so &&
ln -v -sf ../../lib32/libkdb5.so.4 /usr/lib32/libkdb5.so &&
ln -v -sf ../../lib32/libkrb5.so.3 /usr/lib32/libkrb5.so &&
ln -v -sf ../../lib32/libkrb5support.so.0 /usr/lib32/libkrb5support.so &&
mv -v /usr/bin/ksu /bin &&
mv -v /usr/bin/krb5-config{,-n32} &&
ldconfig

64Bit

Build the packge:

cd src &&
CPPFLAGS="-DEAI_NODATA=EAI_NONAME" CC="gcc ${BUILD64}" USE_ARCH=64 \
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var/lib \
   --enable-dns-for-realm --mandir=/usr/share/man --libdir=/usr/lib64 &&
make

Install the package:

make install &&
chmod -v 755 /usr/lib64/lib{krb5support,com_err,k5crypto,krb5}.so* &&
chmod -v 755 /usr/lib64/lib{gssapi_krb5,gssrpc,kdb5,kadm5clnt,kadm5srv}.so* &&
chmod -v 755 /usr/lib64/krb5/plugins/*/*.so &&
mv -v /usr/lib64/libcom_err.so.3* /lib64 &&
mv -v /usr/lib64/libgssapi_krb5.so.2* /lib64 &&
mv -v /usr/lib64/libgssrpc.so.4* /lib64 &&
mv -v /usr/lib64/libk5crypto.so.3* /lib64 &&
mv -v /usr/lib64/libkadm5clnt.so.6* /lib64 &&
mv -v /usr/lib64/libkadm5srv.so.6* /lib64 &&
mv -v /usr/lib64/libkdb5.so.4* /lib64 &&
mv -v /usr/lib64/libkrb5.so.3* /lib64 &&
mv -v /usr/lib64/libkrb5support.so.0* /lib64 &&
ln -v -sf ../../lib64/libcom_err.so.3 /usr/lib64/libcom_err.so &&
ln -v -sf ../../lib64/libgssapi_krb5.so.2 /usr/lib64/libgssapi_krb5.so &&
ln -v -sf ../../lib64/libgssrpc.so.4 /usr/lib64/libgssrpc.so &&
ln -v -sf ../../lib64/libk5crypto.so.3 /usr/lib64/libk5crypto.so &&
ln -v -sf ../../lib64/libkadm5clnt.so.6 /usr/lib64/libkadm5clnt.so &&
ln -v -sf ../../lib64/libkadm5srv.so.6 /usr/lib64/libkadm5srv.so &&
ln -v -sf ../../lib64/libkdb5.so.4 /usr/lib64/libkdb5.so &&
ln -v -sf ../../lib64/libkrb5.so.3 /usr/lib64/libkrb5.so &&
ln -v -sf ../../lib64/libkrb5support.so.0 /usr/lib64/libkrb5support.so &&
mv -v /usr/bin/ksu /bin &&
mv -v /usr/bin/krb5-config{,-64} &&
ln -sfv multiarch_wrapper /usr/bin/krb5-config &&
ldconfig

Configuring

Caution.png

Note

login.krb5 does not support shadow passwords. So, when the Kerberos server is unavailable, the default use of /etc/passwd will not work because the passwords are now in /etc/shadow (where they were put while building CLFS). Entering the following commands without moving the passwords back to /etc/passwd could prevent any logins.

If you have Linux-PAM installed then you can authenticate using the login provided by shadow through the Pam-krb5 module (Recommended). If you understand the above warning and Linux-PAM is not installed, the following commands can be used:

mv -v /bin/login /bin/login.shadow &&
cp -v /usr/sbin/login.krb5 /bin/login

The information in the sections below are based off information from the following pages:

http://www.bayour.com/LDAPv3-HOWTO.html
http://aput.net/~jheiss/krbldap/

Creating a Kerberos Realm

Caution.png

Note

At this point it is strongly recommended that you have a working DNS Server. After setting up a login with Kerberos failure to resolve the name of the KDC server will result in login failures.

Create the db directory exists with the following command:

install -dv -m755 /var/lib/krb5kdc

Create the Kerberos configuration with the following command. It's recommended that the Kerberos Realm be all uppercase.

cat > /etc/krb5.conf << "EOF"
# Begin /etc/krb5.conf

[libdefaults]
    default_realm = <REALMNAME.COM>
    encrypt = true

[kdc]
    profile = /var/lib/krb5kdc/kdc.conf

[appdefaults]
    pam = {
        <REALMNAME.COM> = {
            minimum_uid = 5000
        }
    }

[realms]
    <REALMNAME.COM> = {
        kdc = <servername.realmname.com>
        admin_server = <servername.realmname.com>
        dict_file = /usr/share/dict/words
    }

[domain_realm]
    .<realmname.com> = <REALMNAME.COM>
    <realmname.com> = <REALMNAME.COM>

[logging]
    kdc = SYSLOG[:INFO[:AUTH]]
    admin_server = SYSLOG[INFO[:AUTH]]
    default = SYSLOG[[:SYS]]

# End /etc/krb5.conf
EOF

On the Kerberos Server create the KDC Configuration File:

cat > /var/lib/krb5kdc/kdc.conf << "EOF"
# Begin /var/lib/krb5kdc/kdc.conf

[kdcdefaults]
    kdc_ports = 750,88

[realms]
    <REALMNAME.COM> = {
        database_name = /var/lib/krb5kdc/principal
        admin_keytab = FILE:/var/lib/krb5kdc/kadm5.keytab
        acl_file = /var/lib/krb5kdc/krb5_adm.acl
        key_stash_file = /var/lib/krb5kdc/.k5.<REALMNAME.COM>
        kdc_ports = 750,88
        max_life = 10h 0m 0s
        max_renewable_life = 7d 0h 0m 0s
    }

# End /var/lib/krb5kdc/kdc.conf
EOF

Execute the following command to initialize the Krb5 database:

kdb5_util create -r REALMNAME.COM -s

Create the Admin Service Keytab:

kadmin.local -q "ktadd -k /var/lib/krb5kdc/kadm5.keytab kadmin/admin" &&
kadmin.local -q "ktadd -k /var/lib/krb5kdc/kadm5.keytab kadmin/changepw" &&
chmod 600 /var/lib/krb5kdc/kadm5.keytab

Create a user to administer Kerberos with:

kadmin.local -q "addprinc krbadm@<REALMNAME.COM>"
kadmin.local -q "addprinc krbadm/admin@<REALMNAME.COM>"

Create a basic acl file:

cat > /var/lib/krb5kdc/krb5_adm.acl << "EOF"
kadmin/admin@<REALMNAME.COM>   *
*/admin@<REALMNAME.COM>        *
krbadm@<REALMNAME.COM>         *
*/*@<REALMNAME.COM>            i
EOF

Testing

Start the kdc service with the following command:

/usr/sbin/krb5kdc &

The following command will simulate a login:

kinit <principle name>

To list your current tickets:

klist

Bootscript

Install the init script included in the bootscripts package.

make install-kerberos

Configuring Kerberos Clients

Securly copy /etc/krb5.conf from one of the Kerberos Servers to each of the clients. You should now be able to get a ticket from the KDC. Now would be a good time to test this:

kinit <principal name>

List your tickets with the following command:

klist

Contents

Installed Programs: compile-et, ftp, ftpd, gss-client, gss-server, k5srvutil, kadmin, kadmin.local, kadmind, kadmind4, kdb5_util, kdestroy, kinit, klist, klogind, kpasswd, kprop, kpropd, krb5-send-pr, krb5-config, krb524d, krb524init, krb5kdc, kshd, ksu, ktutil, kvno, login.krb5, rcp, rlogin, rsh, sclient, sim_client, sim_server, sserver, telnet, telnetd, uuclient, uuserver, v5passwd, and v5passwdd
Installed Libraries: libcom_err.{so,a}, libdes425.{so,a}, libgssapi.{so,a}, libgssrpc.{so,a}, libkadm5clnt.{so,a}, libkadm5srv.{so,a}, libkdb5.{so,a}, libkrb5.{so,a}, and libkrb4.{so,a}
Installed Directory: /usr/include/kerberosIV and /var/lib/krb5kdc

Short Descriptions

compile_et converts the table listing error-code names into a C source file.
ftp is a kerberized FTP client.
ftpd is a kerberized FTP daemon.
k5srvutil is a host keytable manipulation utility.
kadmin is an utility used to make modifications to the Kerberos database.
kadmind is a server for administrative access to a Kerberos database.
kdb5_util is the KDC database utility.
kdestroy removes the current set of tickets.
kinit is used to authenticate to the Kerberos server as a principal and acquire a ticket granting ticket that can later be used to obtain tickets for other services.
klist reads and displays the current tickets in the credential cache.
klogind is the server that responds to rlogin requests.
kpasswd is a program for changing Kerberos 5 passwords.
kprop takes a principal database in a specified format and converts it into a stream of database records.
kpropd receives a database sent by kprop and writes it as a local database.
krb5-config gives information on how to link programs against libraries.
krb5kdc is a Kerberos 5 server.
kshd is the server that responds to rsh requests.
ksu is the super user program using Kerberos protocol. Requires a properly configured /etc/shells and ~/.k5login containing principals authorized to become super users.
ktutil is a program for managing Kerberos keytabs.
kvno prints keyversion numbers of Kerberos principals.
login.krb5 is a kerberized login program.
rcp is a kerberized rcp client program.
rlogin is a kerberized rlogin client program.
rsh is a kerberized rsh client program.
telnet is a kerberized telnet client program.
telnetd is a kerberized telnet server.
libcom_err.{so,a} implements the Kerberos library error code.
libgssapi.{so,a} contain the Generic Security Service Application Programming Interface (GSSAPI) functions which provides security services to callers in a generic fashion, supportable with a range of underlying mechanisms and technologies and hence allowing source-level portability of applications to different environments.
libkadm5clnt.{so,a} contains the administrative authentication and password checking functions required by Kerberos 5 client-side programs.
libkadm5srv.{so,a} contain the administrative authentication and password checking functions required by Kerberos 5 servers.
libkdb5.{so,a} is a Kerberos 5 authentication/authorization database access library.
libkrb5.{so,a} is an all-purpose Kerberos 5 library.