{"id":230,"date":"2014-03-01T07:51:33","date_gmt":"2014-03-01T07:51:33","guid":{"rendered":"https:\/\/digitalchild.info\/?p=230"},"modified":"2014-03-01T07:51:33","modified_gmt":"2014-03-01T07:51:33","slug":"active-directory-authentication-with-centos","status":"publish","type":"post","link":"https:\/\/randomadult.local\/active-directory-authentication-with-centos\/","title":{"rendered":"Active Directory Authentication with CentOS"},"content":{"rendered":"

Active directory authentication for CentOS is quite easy to configure. Active directory is a central authentication system and organisations all over the world have relied on it for years. This is super easy to set up for your Windows and Mac desktops but is sometimes\u00a0a little harder with a Linux workstation. This is all done on a CentOS 6.5 minimal install with nothing but a LAMP stack installed.<\/p>\n

There are is one step you need to take to get your machine ready for configuration. Install the following packages, if they aren’t already.<\/p>\n

\n\n# yum -y install authconfig krb5-workstation pam_krb5 samba-common oddjob-mkhomedir\n\n<\/pre>\n

This will install everything you need to get up and running. There is two ways you can configure the authentication. From the command line (authconfig) or via a console GUI (authconfig-tui). It all works just depends on which version you are comfortable with.<\/p>\n

Authconfig<\/strong><\/h3>\n
\n# authconfig --disablecache --enablewinbind --enablewinbindauth --smbsecurity=ads --smbworkgroup=DOMAIN --smbrealm=DOMAIN.COM.AU --enablewinbindusedefaultdomain --winbindtemplatehomedir=\/home\/DOMAIN\/%U --winbindtemplateshell=\/bin\/bash --enablekrb5 --krb5realm=DOMAIN.COM.AU --enablekrb5kdcdns --enablekrb5realmdns --enablelocauthorize --enablemkhomedir --enablepamaccess --updateall\n\n<\/pre>\n

This will setup the necessary config files for both Kerberos and Samba. There is more config files to update from here.\u00a0<\/span><\/p>\n

Please Note:\u00a0When I ran this I got an error with Oddjobd not being able to start.\u00a0You can read the details in this post<\/a>. Just\u00a0make sure\u00a0that the\u00a0messagebus<\/em><\/strong>\u00a0service is running.<\/p>\n

Kerberos (\/etc\/krb5.conf<\/strong>)\u00a0<\/em><\/p>\n

Check that the file was generated and then add the relevant realms and domain_realm<\/strong> for your domain to the file. If you have multiple domain controllers you can add extra kdc<\/strong><\/em> lines like below.<\/p>\n

\n[logging]\n default = FILE:\/var\/log\/krb5libs.log\n kdc = FILE:\/var\/log\/krb5kdc.log\n admin_server = FILE:\/var\/log\/kadmind.log\n\n[libdefaults]\n default_realm = DOMAIN.COM.AU\n dns_lookup_realm = false\n dns_lookup_kdc = false\n ticket_lifetime = 24h\n renew_lifetime = 7d\n forwardable = true\n\n[realms]\n EXAMPLE.COM = {\n kdc = kerberos.example.com\n admin_server = kerberos.example.com\n }\n\nDOMAIN.COM.AU = {\nadmin_server = domain.com.au\nkdc = dc1.domain.com.au\nkdc = dc2.domain.com.au\n}\n\n[domain_realm]\n .example.com = EXAMPLE.COM\n example.com = EXAMPLE.COM\n domain.com.au = DOMAIN.COM.AU\n .domain.com.au = DOMAIN.COM.AU\n\n<\/pre>\n

Save the file and test that it works using the kinit<\/em><\/strong> command.<\/p>\n

\n\n# kinit someaduser\n\n<\/pre>\n

A password prompt will be displayed, type in the active directory password for that user and it\u00a0should return to the prompt with no messages. You can then check that you have your kerberos ticket by running the klist<\/em><\/strong> command. It should output something like the following.<\/p>\n

\n\nTicket cache: FILE:\/tmp\/krb5cc_0\nDefault principal: someaduser@DOMAIN.COM.AU\n\nValid starting Expires Service principal\n02\/27\/14 12:23:21 02\/27\/14 22:23:21 krbtgt\/DOMAIN.COM.AU@DOMAIN.COM.AU\n renew until 03\/06\/14 12:23:19\n\n<\/pre>\n

Join the Domain<\/em><\/strong><\/p>\n

You’re now ready to join the machine to the domain. You can use the trusty net<\/strong><\/em> command to join the machine to the domain.<\/p>\n

\n\n# net ads join domain.com.au -U someadadmin\n\n<\/pre>\n

You can test that this worked running the following command<\/p>\n

\n\n# net ads testjoin\nJoin is OK\n\n<\/pre>\n

Console GUI<\/strong><\/h3>\n

The other option to configure AD authentication\u00a0is to use the console GUI version of authconfig. This will pop up a familiar looking interface (think console RedHat installer) that is pretty straight forward when it comes to configuration. Start the GUI tool<\/p>\n

\n\n# authconfig-tui\n\n<\/pre>\n

You will get a screen like the following, make sure that only the items checked are the same as below.<\/p>\n

\"authconfig-tui-1\"<\/p>\n

User Information<\/em><\/p>\n