posts - 496,comments - 227,trackbacks - 0
http://www.blogjava.net/ivanwan/archive/2012/12/19/393221.html

https://help.ubuntu.com/10.04/serverguide/kerberos.html

kerberos

kerberos is a network authentication system based on the principal of a trusted third party. the other two parties being the user and the service the user wishes to authenticate to. not all services and applications can use kerberos, but for those that can, it brings the network environment one step closer to being single sign on (sso).

this section covers installation and configuration of a kerberos server, and some example client configurations.

overview

if you are new to kerberos there are a few terms that are good to understand before setting up a kerberos server. most of the terms will relate to things you may be familiar with in other environments:

  • principal: any users, computers, and services provided by servers need to be defined as kerberos principals.

  • instances: are used for service principals and special administrative principals.

  • realms: the unique realm of control provided by the kerberos installation. usually the dns domain converted to uppercase (example.com).

  • key distribution center: (kdc) consist of three parts, a database of all principals, the authentication server, and the ticket granting server. for each realm there must be at least one kdc.

  • ticket granting ticket: issued by the authentication server (as), the ticket granting ticket (tgt) is encrypted in the user's password which is known only to the user and the kdc.

  • ticket granting server: (tgs) issues service tickets to clients upon request.

  • tickets: confirm the identity of the two principals. one principal being a user and the other a service requested by the user. tickets establish an encryption key used for secure communication during the authenticated session.

  • keytab files: are files extracted from the kdc principal database and contain the encryption key for a service or host.

to put the pieces together, a realm has at least one kdc, preferably two for redundancy, which contains a database of principals. when a user principal logs into a workstation, configured for kerberos authentication, the kdc issues a ticket granting ticket (tgt). if the user supplied credentials match, the user is authenticated and can then request tickets for kerberized services from the ticket granting server (tgs). the service tickets allow the user to authenticate to the service without entering another username and password.

kerberos server

installation

before installing the kerberos server a properly configured dns server is needed for your domain. since the kerberos realm by convention matches the domain name, this section uses the example.com domain configured in .

also, kerberos is a time sensitive protocol. so if the local system time between a client machine and the server differs by more than five minutes (by default), the workstation will not be able to authenticate. to correct the problem all hosts should have their time synchronized using the network time protocol (ntp). for details on setting up ntp see .

the first step in installing a kerberos realm is to install the krb5-kdc and krb5-admin-server packages. from a terminal enter:

sudo apt-get install krb5-kdc krb5-admin-server 

you will be asked at the end of the install to supply a name for the kerberos and admin servers, which may or may not be the same server, for the realm.

next, create the new realm with the kdb5_newrealm utility:

sudo krb5_newrealm 

configuration

the questions asked during installation are used to configure the /etc/krb5.conf file. if you need to adjust the key distribution center (kdc) settings simply edit the file and restart the krb5-kdc daemon.

  1. now that the kdc running an admin user is needed. it is recommended to use a different username from your everyday username. using the kadmin.local utility in a terminal prompt enter:

    sudo kadmin.local authenticating as principal root/admin@example.com with password. kadmin.local: addprinc steve/admin warning: no policy specified for steve/admin@example.com; defaulting to no policy enter password for principal "steve/admin@example.com":  re-enter password for principal "steve/admin@example.com":  principal "steve/admin@example.com" created. kadmin.local: quit 

    in the above example steve is the principal, /admin is an instance, and @example.com signifies the realm. the "every day" principal would be steve@example.com, and should have only normal user rights.


    replace example.com and steve with your realm and admin username.

  2. next, the new admin user needs to have the appropriate access control list (acl) permissions. the permissions are configured in the /etc/krb5kdc/kadm5.acl file:

    steve/admin@example.com        * 

    this entry grants steve/admin the ability to perform any operation on all principals in the realm.

  3. now restart the krb5-admin-server for the new acl to take affect:

    sudo /etc/init.d/krb5-admin-server restart 
  4. the new user principal can be tested using the kinit utility:

    kinit steve/admin steve/admin@example.com's password: 

    after entering the password, use the klist utility to view information about the ticket granting ticket (tgt):

    klist credentials cache: file:/tmp/krb5cc_1000         principal: steve/admin@example.com    issued           expires          principal jul 13 17:53:34  jul 14 03:53:34  krbtgt/example.com@example.com 

    you may need to add an entry into the /etc/hosts for the kdc. for example:

    192.168.0.1   kdc01.example.com       kdc01 

    replacing 192.168.0.1 with the ip address of your kdc.

  5. in order for clients to determine the kdc for the realm some dns srv records are needed. add the following to /etc/named/db.example.com:

    _kerberos._udp.example.com.     in srv 1  0 88  kdc01.example.com. _kerberos._tcp.example.com.     in srv 1  0 88  kdc01.example.com. _kerberos._udp.example.com.     in srv 10 0 88  kdc02.example.com.  _kerberos._tcp.example.com.     in srv 10 0 88  kdc02.example.com.  _kerberos-adm._tcp.example.com. in srv 1  0 749 kdc01.example.com. _kpasswd._udp.example.com.      in srv 1  0 464 kdc01.example.com. 

    replace example.com, kdc01, and kdc02 with your domain name, primary kdc, and secondary kdc.

    see for detailed instructions on setting up dns.

your new kerberos realm is now ready to authenticate clients.

secondary kdc

once you have one key distribution center (kdc) on your network, it is good practice to have a secondary kdc in case the primary becomes unavailable.

  1. first, install the packages, and when asked for the kerberos and admin server names enter the name of the primary kdc:

    sudo apt-get install krb5-kdc krb5-admin-server 
  2. once you have the packages installed, create the secondary kdc's host principal. from a terminal prompt, enter:

    kadmin -q "addprinc -randkey host/kdc02.example.com" 

    after, issuing any kadmin commands you will be prompted for your username/admin@example.com principal password.

  3. extract the keytab file:

    kadmin -q "ktadd -k keytab.kdc02 host/kdc02.example.com" 
  4. there should now be a keytab.kdc02 in the current directory, move the file to /etc/krb5.keytab:

    sudo mv keytab.kdc02 /etc/krb5.keytab 

    if the path to the keytab.kdc02 file is different adjust accordingly.

    also, you can list the principals in a keytab file, which can be useful when troubleshooting, using the klist utility:

    sudo klist -k /etc/krb5.keytab 
  5. next, there needs to be a kpropd.acl file on each kdc that lists all kdcs for the realm. for example, on both primary and secondary kdc, create /etc/krb5kdc/kpropd.acl:

    host/kdc01.example.com@example.com host/kdc02.example.com@example.com 
  6. create an empty database on the secondary kdc:

    sudo kdb5_util -s create 
  7. now start the kpropd daemon, which listens for connections from the kprop utility. kprop is used to transfer dump files:

    sudo kpropd -s 
  8. from a terminal on the primary kdc, create a dump file of the principal database:

    sudo kdb5_util dump /var/lib/krb5kdc/dump 
  9. extract the primary kdc's keytab file and copy it to /etc/krb5.keytab:

    kadmin -q "ktadd -k keytab.kdc01 host/kdc01.example.com" sudo mv keytab.kdc01 /etc/kr5b.keytab 

    make sure there is a host for kdc01.example.com before extracting the keytab.

  10. using the kprop utility push the database to the secondary kdc:

    sudo kprop -r example.com -f /var/lib/krb5kdc/dump kdc02.example.com 

    there should be a succeeded message if the propagation worked. if there is an error message check /var/log/syslog on the secondary kdc for more information.

    you may also want to create a cron job to periodically update the database on the secondary kdc. for example, the following will push the database every hour:

    # m h  dom mon dow   command 0 * * * * /usr/sbin/kdb5_util dump /var/lib/krb5kdc/dump && /usr/sbin/kprop -r example.com -f /var/lib/krb5kdc/dump kdc02.example.com 
  11. back on the secondary kdc, create a stash file to hold the kerberos master key:

    sudo kdb5_util stash 
  12. finally, start the krb5-kdc daemon on the secondary kdc:

    sudo /etc/init.d/krb5-kdc start 

the secondary kdc should now be able to issue tickets for the realm. you can test this by stopping the krb5-kdc daemon on the primary kdc, then use kinit to request a ticket. if all goes well you should receive a ticket from the secondary kdc.

kerberos linux client

this section covers configuring a linux system as a kerberos client. this will allow access to any kerberized services once a user has successfully logged into the system.

installation

in order to authenticate to a kerberos realm, the krb5-user and libpam-krb5 packages are needed, along with a few others that are not strictly necessary but make life easier. to install the packages enter the following in a terminal prompt:

sudo apt-get install krb5-user libpam-krb5 libpam-ccreds auth-client-config 

the auth-client-config package allows simple configuration of pam for authentication from multiple sources, and the libpam-ccreds will cache authentication credentials allowing you to login in case the key distribution center (kdc) is unavailable. this package is also useful for laptops that may authenticate using kerberos while on the corporate network, but will need to be accessed off the network as well.

configuration

to configure the client in a terminal enter:

sudo dpkg-reconfigure krb5-config 

you will then be prompted to enter the name of the kerberos realm. also, if you don't have dns configured with kerberos srv records, the menu will prompt you for the hostname of the key distribution center (kdc) and realm administration server.

the dpkg-reconfigure adds entries to the /etc/krb5.conf file for your realm. you should have entries similar to the following:

[libdefaults]         default_realm = example.com ... [realms]         example.com = }                                 kdc = 192.168.0.1                                admin_server = 192.168.0.1         } 

you can test the configuration by requesting a ticket using the kinit utility. for example:

kinit steve@example.com password for steve@example.com: 

when a ticket has been granted, the details can be viewed using klist:

klist ticket cache: file:/tmp/krb5cc_1000 default principal: steve@example.com  valid starting     expires            service principal 07/24/08 05:18:56  07/24/08 15:18:56  krbtgt/example.com@example.com         renew until 07/25/08 05:18:57   kerberos 4 ticket cache: /tmp/tkt1000 klist: you have no tickets cached 

next, use the auth-client-config to configure the libpam-krb5 module to request a ticket during login:

sudo auth-client-config -a -p kerberos_example 

you will should now receive a ticket upon successful login authentication.

resources

  • for more information on kerberos see the site.

  • the page has more details.

  • o'reilly's is a great reference when setting up kerberos.

  • also, feel free to stop by the #ubuntu-server irc channel on if you have kerberos questions.

posted on 2016-07-05 11:37 simone 阅读(1765) 评论(0)  编辑  收藏

只有注册用户后才能发表评论。


网站导航:
              
 
"));
网站地图