Linux-AD Integration With Windows Server 2003 R227 April 2006
The integration of (what was formerly called) Services for UNIX into Windows Server 2003 R2 also brought some other changes. To accommodate those changes, I’ve updated my Linux-AD integration instructions (the previous instructions are here for pre-R2 versions of Windows). If you need to integrate Linux systems for authentication into Active Directory with Windows Server 2003 R2, these instructions should get you there.
Overall, the instructions are very similar to the instructions for pre-R2 versions of Windows.
Preparing Active Directory (One-Time)
Based on what I’ve seen so far, it appears as if a partial RFC 2307-compliant schema is included by default with Windows Server 2003 R2. This means that it is no longer necessary to extend the schema to include attributes such as uid, gid, login shell, etc. However, while the schema does appear to be present by default, you must install the “Server for NIS” component on at least one domain controller in order to be able to actually set those attributes (and it will be necessary to set the attributes before logins from Linux will work).
You’ll also need to create an account in Active Directory that will be used to bind to Active Directory for LDAP queries. This account does not need any special privileges; in fact, making the account a member of Domain Guests and not a member of Domain Users is perfectly fine.
Preparing Active Directory (Each User)
Each Active Directory account that will authenticate via Linux must be configured with a UID and other UNIX attributes. This is accomplished via the new “UNIX Attributes” tab on the properties dialog box of a user account. Installing the “Server for NIS” component enables this, as mentioned previously.
After all the user accounts have been configured, then we are ready to perform the additional tasks within Active Directory and on the Linux server that will enable the authentication.
Preparing Active Directory (Each Server)
For each Linux-based server that will be authenticating against Active Directory, follow the steps below.
Create a computer account in Active Directory. When creating the computer account, be sure to specify that this account may be used by a pre-Windows 2000-based computer.
Use the following command at a command prompt to configure the new computer account:
ktpass -princ host/fqdn@REALM -mapuser DOMAIN\name$ -crypto DES-CBC-MD5 -pass password -ptype KRB5_NT_PRINCIPAL -out filename
Of course, you’ll need to substitute the appropriate values for “fqdn” (the fully-qualified domain name of the computer), “REALM” (the DNS name of your Active Directory domain in UPPERCASE), “DOMAIN” (the NetBIOS name of your Active Directory domain), “password” (the password that will be set for the new computer account), and “filename” (the keytab that will be generated and must be copied over to the Linux computer).
If you need to rebuild the Linux server for whatever reason, you’ll need to delete the computer account you created and repeat this process.
Preparing Each Linux Server
Follow the steps below to configure the Linux server for authentication against Active Directory.
Make sure that the appropriate Kerberos libraries, OpenLDAP, pam_krb5, and nss_ldap are installed. If they are not installed, install them.
Be sure that time is being properly synchronized between Active Directory and the Linux server in question. Kerberos requires time synchronization.
krb5.conffile to look something like this, substituting your actual host names and domain names where appropriate:
/etc/ldap.conffile to look something like this, substituting the appropriate host names, domain names, account names, and distinguished names (DNs) where appropriate.
Securely copy the file created using the
ktpass.exeutility above to the Linux server in question, placing it in the
krb5.keytab. (SFTP or SCP are excellent candidates for this.)
Configure PAM (this varies according to Linux distributions) to use pam_krb5 for authentication. Many modern distributions use a stacking mechanism whereby one file can be modified and those changes will applied to all the various PAM-aware services. For example, in Red Hat-based distributions, the system-auth file is referenced by most other PAM-aware services.
/etc/nsswitch.conffile to include “ldap” as a lookup source for passwd, shadow, and groups.
That should be it. Once you do that, you should be able to use
kinit from a Linux shell prompt (for example,
kinit aduser) and generate a valid Kerberos ticket for the specified Active Directory account.
At this point, any PAM-aware service that is configured to use the stacked system file (such as the system-auth configuration on Red Hat-based distributions) will use Active Directory for authentication. Note, however, that unless you also add the pam_mkhomedir.so module in the PAM configuration, home directories will have to be created manually for any Active Directory account that may log on to that server. (I generally recommend the use of pam_mkhomedir.so in this situation.)
This configuration was tested on Red Hat Linux 9.0 as well as CentOS 4.3.
UPDATE: An updated version of these instructions has been posted.Tags: ActiveDirectory · CentOS · Kerberos · LDAP · Linux · Networking · OSS · RedHat · Windows Previous Post: Windows Server Update Services Next Post: CentOS on ESX Server