<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Gavin Adams Information Blog &#187; CentOS 5.2</title>
	<atom:link href="http://www.gavinadams.org/blog/category/tech-tips/centos-52/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gavinadams.org/blog</link>
	<description>Musings on hobbies, technology and topics of interest</description>
	<lastBuildDate>Sat, 25 Jun 2011 14:22:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>CentOS 5.2 &#8211; Apache &#8211; Kerberos / Active Directory Authentication</title>
		<link>http://www.gavinadams.org/blog/2009/03/25/centos-52-apache-kerberos-active-directory-authentication/</link>
		<comments>http://www.gavinadams.org/blog/2009/03/25/centos-52-apache-kerberos-active-directory-authentication/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 19:36:40 +0000</pubDate>
		<dc:creator>me@gavinadams.org</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[CentOS 5.2]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Centos]]></category>
		<category><![CDATA[Kerberos]]></category>
		<category><![CDATA[Microsoft Windows]]></category>

		<guid isPermaLink="false">http://www.gavinadams.org/blog/?p=35</guid>
		<description><![CDATA[<p>Linux and Windows Active Directory (AD) integration has come a long ways since 2000. It is now quite easy to take advantage of Kerberos for managing authentication at the host level (user logins and such). Surprisingly, it&#8217;s just as easy to the same in Apache now.</p> <p>This posting will walk you through the steps needed [...]]]></description>
			<content:encoded><![CDATA[<p>Linux and Windows Active Directory (AD) integration has come a long ways since 2000. It is now quite easy to take advantage of Kerberos for managing authentication at the host level (user logins and such). Surprisingly, it&#8217;s just as easy to the same in Apache now.</p>
<p>This posting will walk you through the steps needed to configure and test authentication against a valid AD user.</p>
<h3>Prerequisites</h3>
<p>It is assumed the following prerequisites are in place:</p>
<ul>
<li>CentOS 5.2 Server &#8211; fully updated</li>
<li>Apache, Kerberos, and supporting packages installed</li>
<li>Samba configured as member server (net ads join has been successfully performed)</li>
<li>Windows Server 2003 R2 or 2008 SP1 with UNIX Identity Management extensions installed</li>
<li>Kerberos working (kinit from a AD user properly authenticates and klist shows tickets)</li>
</ul>
<p><span id="more-35"></span>If possible, test this from a freshly installed machine. In this example, the following servers and realms will be referenced:</p>
<pre style="padding-left: 30px;">AD Server       dc01.example.com
Linux Server    www.example.com
Computer Object www
Kerberos Realm  EXAMPLE.COM</pre>
<h3>Creating the SPN</h3>
<p>Kerberos uses a <em>service principal name </em>for each service available on the host. For a server that can authenticate against AD, this would include at least the HOST principal. From the AD server, issue the setspn command to view the current SPN&#8217;s assigned to www.example.com (use the canonical name for www, not the FQDN):</p>
<pre style="padding-left: 30px;">C:\&gt;<strong>setspn -L www</strong>
Registered ServicePrincipalNames for CN=www,CN=Computers,DC=example,DC=com:
        HOST/www
        HOST/www.example.com</pre>
<p>Now as root on www issue the command to create the HTTP SPN (the net ads command is provided by the samba packages&#8211;make sure these are installed even if they are not used):</p>
<pre style="padding-left: 30px;">[root@www /]#<strong> net ads keytab add HTTP -U administrator</strong>
Processing principals to add...
administrator's password: <strong>*******</strong></pre>
<p>The -U is used to provide an administrator account with Domain Admin privileges. This step has added the SPN which we&#8217;ll see in AD, and it has also updated the local keytab file /etc/krb5.keytab with the SPN bits.</p>
<p>To verify the SPN has been created properly, issue the same setspn command and verify there are entries for HTTP. It should look something like this:</p>
<pre style="padding-left: 30px;">C:\&gt;<strong>setspn -L www</strong>
Registered ServicePrincipalNames for CN=www,CN=Computers,DC=example,DC=com:
        HTTP/www
        HTTP/www.example.com
        HOST/www
        HOST/www.example.com</pre>
<h3>Configure Apache</h3>
<p>Make sure the package mod_auth_kerb is installed. This should create the configuration file in /etc/httpd/conf.d/auth_kerb.conf which will load the Kerberos module and provide a commented out example (which we&#8217;ll use). First, because httpd runs as apache, we need to copy the keytab file and change permissions so that apache can read it. I&#8217;ve placed it in the default specified in the auth_kerb.conf file:</p>
<pre style="padding-left: 30px;">[root@www /]#<strong> cp /etc/krb5.keytab /etc/httpd/conf/keytab2</strong>
[root@www /]# <strong>ls -l /etc/httpd/conf</strong>
total 64
-rw-r--r-- 1 root   root   33760 Mar 25 14:01 httpd.conf
---------- 1 root   root    1321 Mar 25 15:06 keytab
-rw-r--r-- 1 root   root   12958 Nov 12 10:43 magic
[root@www /]# <strong>chown apache.apache /etc/httpd/conf/keytab2</strong>
[root@www /]# <strong>chmod 400 /etc/httpd/conf/keytab2</strong>
[root@www /]# <strong>ls -l /etc/httpd/conf</strong>
total 64
-rw-r--r-- 1 root   root   33760 Mar 25 14:01 httpd.conf
-r-------- 1 apache apache  1321 Mar 25 15:06 keytab
-rw-r--r-- 1 root   root   12958 Nov 12 10:43 magic</pre>
<h3>Create an Apache Location for Testing</h3>
<p>Now modify the &#8220;private&#8221; location and uncomment the directives and set them for the realm (changes from defaults in bold):</p>
<pre style="padding-left: 30px;">[root@www /]# vi /etc/http/conf.d/auth_kerb.conf# The mod_auth_kerb module implements Kerberos authentication over
# HTTP, following the "Negotiate" protocol.
#
LoadModule auth_kerb_module modules/mod_auth_kerb.so
#
# Sample configuration: Kerberos authentication must only be
# used over SSL to prevent replay attacks.  The keytab file
# configured must be readable only by the "apache" user, and
# must contain service keys for "HTTP/www.example.com", where
# "www.example.com" is the FQDN of this server.
#

#&lt;Location /private&gt;
#  SSLRequireSSL
 AuthType Kerberos
 AuthName "Kerberos Login"
 KrbMethodNegotiate On
 KrbMethodK5Passwd <strong>On</strong>
 KrbAuthRealms <strong>EXAMPLE.COM</strong>
 Krb5KeyTab /etc/httpd/conf/keytab
 require valid-user
&lt;/Location&gt;</pre>
<p>Create the directory (/var/www/html/private) and a test HTML file in the directory (index.html). Restart httpd and navigate to the URL (http://www.example.com/private/index.html). You should be prompted for credentials. Using a valid AD user and password should get you in. A side benefit is that if logged into a workstation within the domain (e.g., Windows XP, Vista, etc), using Internet Explorer should use your Kerberos credentials to authenticate.</p>
<h3>Uses</h3>
<p>For production use, any application or web service that can use Apache&#8217;s authentication mechanisms should work. Take care to understand that even if you enter a short username, the realm will be appended onto the end. In this example, the username gadams would appear as gadams@EXAMPLE.COM in the log files, and probably be presented to the referenced application.</p>
<h3>Credit</h3>
<p>I&#8217;d like to <a href="http://blog.scottlowe.org/" target="_blank">Scott Lowe </a>for all the articles he has done on Linux / AD / Kerberos integration, and<a href="http://blog.scottlowe.org/2006/08/10/kerberos-based-sso-with-apache/" target="_blank"> this article</a>, which was where I started my CentOS / Apache / Kerberos / AD journey. His article covers all the basics, but a lot has changed (for the better) since 2006. Thanks Scott!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavinadams.org/blog/2009/03/25/centos-52-apache-kerberos-active-directory-authentication/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

