{"id":6533,"date":"2017-03-09T19:25:18","date_gmt":"2017-03-09T11:25:18","guid":{"rendered":"http:\/\/rmohan.com\/?p=6533"},"modified":"2017-03-09T19:29:12","modified_gmt":"2017-03-09T11:29:12","slug":"add-a-red-hat-enterprise-linux-6-system-to-microsoft-active-directory","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6533","title":{"rendered":"Add a Red Hat Enterprise Linux 6 system to Microsoft Active Directory"},"content":{"rendered":"<p>Add a Red Hat Enterprise Linux 6 system to Microsoft Active Directory<\/p>\n<p>UPDATE!! .. This article also works perfectly on Windows 2012 Server as well as Windows Server 2008. The process is exactly the same.<\/p>\n<p>I\u2019ve had countless numbers of people ask me over the years how to add a Linux system to Active Directory.<\/p>\n<p>Here is a really quick and simple way to do it using Windbind for userlookups, and Kerberos for authentication.<\/p>\n<p>In this example, I will be using the below details<\/p>\n<p>Windows Domain Name:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rmohan.com<br \/>\nWindows Domain NetBIOS Name: RMOHAN<br \/>\nDomain Controller:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 dc1.rmohan.com<br \/>\nClient Server name:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 server01.rmohan.com<\/p>\n<p>Setup<\/p>\n<p>1. Firstly, install the necessary components.<\/p>\n<p>yum install -y samba-winbind samba-winbind-clients oddjob-mkhomedir pam_krb5 krb5-workstation<\/p>\n<p>2. Make sure OddJobd is running at Startup. This is only for Red Hat Enterprise Linux 6 and other Red Hat based Operating systems.<\/p>\n<p>Red Hat Enterprise Linux 5 will use pam_mkhomedir. pam_mkhomedir has SELinux issues at present, so oddjobd is the way to go.<\/p>\n<p>chkconfig oddjobd on<\/p>\n<p>3. Set authconfig to point to the relevant systems for Authentication.<br \/>\nNote: If you do not wish your users to log into your server via a shell, set \u2013winbindtemplateshell to \u2013winbindtemplateshell=\/sbin\/nologin<\/p>\n<p>authconfig &#8211;update &#8211;kickstart &#8211;enablewinbind &#8211;smbsecurity=ads &#8211;smbworkgroup=RMOHAN &#8211;smbrealm=rmohan.com &#8211;winbindtemplatehomedir=\/home\/%U &#8211;winbindtemplateshell=\/bin\/bash &#8211;enablewinbindusedefaultdomain &#8211;enablelocauthorize &#8211;enablekrb5 &#8211;krb5realm=RMOHAN.COM &#8211;enablekrb5kdcdns &#8211;enablekrb5realmdns &#8211;enablepamaccess<\/p>\n<p>4. Just like in Windows, Add your system to the domain. Here I have used the Domain Administrator account, but any account with enough rights to add a system to the domain will suffice.<\/p>\n<p>[root@server ~]# net ads join -U Administrator<br \/>\nEnter Administrator&#8217;s password:<br \/>\nUsing short domain name &#8212; RMOHAN<br \/>\nJoined &#8216;server&#8217; to realm &#8216;rmohan.com&#8217;<\/p>\n<p>Note: As you are now dealing with Active Directory, it now becomes time sensitive. Make sure your system clock is pointing to one of your Domain Controllers as the RMOHANP server.<\/p>\n<p>Otherwise you will end up with errors like this when you try to add the system to the domain.<\/p>\n<p>[root@server ~]# net ads join -U Administrator<br \/>\nEnter Administrator&#8217;s password:<br \/>\nUsing short domain name &#8212; RMOHAN<br \/>\nJoined &#8216;SERVER&#8217; to realm &#8216;rmohan.com&#8217;<br \/>\n[2012\/07\/06 17:24:04.397769,\u00a0 0] libads\/kerberos.c:333(ads_kinit_password)<br \/>\nkerberos_kinit_password SERVER$@RMOHAN.EXAMPLE.COM failed: Clock skew too great<br \/>\n[root@server ~]#<\/p>\n<p>5. Configure Winbind Backend<br \/>\nThe default Winbind backend is great for single systems being added to Active Directory, however if you are in a very large Linux estate like I usually am, you will need to change the backend to ensure that all UID\u2019s\/GID\u2019s match across all your systems.<\/p>\n<p>To do this, add the below two lines to your global Samba configuration. Replace \u201cRMOHAN\u201d with your own Domain name.<\/p>\n<p>idmap config RMOHAN:backend = rid<br \/>\nidmap config RMOHAN:range = 10000000-19999999<br \/>\nkerberos method = dedicated keytab<br \/>\ndedicated keytab file=\/etc\/krb5.keytab<\/p>\n<p>Just so we are on the same page, my global configuration now looks like this<\/p>\n<p>workgroup = RMOHAN<br \/>\nrealm = RMOHAN.EXAMPLE.COM<br \/>\nsecurity = ads<br \/>\nidmap uid = 16777216-33554431<br \/>\nidmap gid = 16777216-33554431<br \/>\nidmap config RMOHAN:backend = rid<br \/>\nidmap config RMOHAN:range = 10000000-19999999<br \/>\nkerberos method = dedicated keytab<br \/>\ndedicated keytab file=\/etc\/krb5.keytab<br \/>\ntemplate homedir = \/home\/%U<br \/>\ntemplate shell = \/bin\/bash<br \/>\nwinbind use default domain = true<br \/>\nwinbind offline logon = false<\/p>\n<p>6. Restart Winbind service<br \/>\nOnce you have added your system to the domain, it is important to restart the Winbind service.<\/p>\n<p>[root@server ~]# service winbind restart<br \/>\nShutting down Winbind services:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [FAILED]<br \/>\nStarting Winbind services:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [\u00a0 OK\u00a0 ]<br \/>\n[root@server ~]#<\/p>\n<p>7. Create a Kerberos keytab to enable Single Sign On (SSO)<\/p>\n<p>[root@server ~]# net ads keytab create -U Administrator<br \/>\nEnter Administrator&#8217;s password:<br \/>\n[root@server ~]#<\/p>\n<p>8. Test configuration. If you receive no output for a known username, then something is wrong.<\/p>\n<p>[root@server ~]# getent passwd Administrator<br \/>\nadministrator:*:16777216:16777216:Administrator:\/home\/administrator:\/bin\/bash<br \/>\n[root@server ~]#<\/p>\n<p>or, if you enabled shell logins,<\/p>\n<p>User@workstation:~$ ssh Administrator@server.rmohan.com<br \/>\nAdministrator@server.rmohan.com&#8217;s password:<br \/>\nYour password will expire in 11 days.<\/p>\n<p>Creating home directory for administrator.<br \/>\n[administrator@server ~]$<\/p>\n<p>9. This is optional, your home directory will not exist on the system when a new user logs in, run the below command if you with to have the homedir automatically created on first login.<\/p>\n<p>[root@server ~]# authconfig &#8211;enablemkhomedir &#8211;update<br \/>\nStarting Winbind services:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [\u00a0 OK\u00a0 ]<br \/>\nStarting oddjobd:\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 [\u00a0 OK\u00a0 ]<br \/>\n[root@server ~]#<\/p>\n<p>&nbsp;<\/p>\n<p>authconfig &#8211;enablemkhomedir &#8211;update<\/p>\n<p>service messagebus restart<\/p>\n<p>\/etc\/init.d\/oddjobd restart<\/p>\n<p>service winbind restart<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<header class=\"entry-header\">\n<h1 class=\"entry-title\">Oddjobd fails to start [FIXED]<\/h1>\n<p class=\"entry-meta\">\n<\/header>\n<div class=\"entry-content\">\n<p>I was configuring a new CentOS 6.5 machine to accept Active Directory logins and up until recently you could use the trust pam_mkhomedir.so to auto create home directories on login. This has since been replaced by a new system called Oddjobd and after the standard authconfig tool I enabled the auto create home directories and then Oddjobd fails to start.<\/p>\n<div>\n<div id=\"highlighter_357378\" class=\"syntaxhighlighter  plain\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"plain plain\">[root@host ~]# service oddjobd start<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"plain plain\">Starting oddjobd:\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [ FAILED ]<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>I did a bit of searching and couldn\u2019t find anything in the logs on the machine or on the net with regards to this. So here is the post. Oddjobd requires access to the system message bus (dbus) and when trying to login to the machine with an AD account I got an error message.<\/p>\n<div>\n<div id=\"highlighter_286275\" class=\"syntaxhighlighter  plain\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"plain plain\">org.freedesktop.DBus.Error.FileNotFound: Failed to connect to socket \/var\/run\/dbus\/system_bus_socket: No such file or directory<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>This pointed out that the message bus wasn\u2019t working or was broken. So first thing I did was check the status of the messagebus and it wasn\u2019t running. I started up messagebus service and then oddjobd started fine.<\/p>\n<div>\n<div id=\"highlighter_938289\" class=\"syntaxhighlighter  plain\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"plain plain\">[root@host ~]# service messagebus restart<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"plain plain\">Stopping system message bus: \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [ FAILED ]<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"plain plain\">Starting system message bus: \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 [ OK ]<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"plain plain\">[root@host ~]# service oddjobd start<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"plain plain\">Starting oddjobd: \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0[\u00a0OK\u00a0]<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"plain plain\">[root@host ~]#<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>I was then able to login with my AD user and it auto created the home directory as required .<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Add a Red Hat Enterprise Linux 6 system to Microsoft Active Directory<\/p>\n<p>UPDATE!! .. This article also works perfectly on Windows 2012 Server as well as Windows Server 2008. The process is exactly the same.<\/p>\n<p>I\u2019ve had countless numbers of people ask me over the years how to add a Linux system to Active Directory.<\/p>\n<p> [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6533"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6533"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6533\/revisions"}],"predecessor-version":[{"id":6536,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6533\/revisions\/6536"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}