r/sysadmin • Systems Engineer, VCP5 • Oct 20 '12

Linux AD login authentication - Do you do it and how?

Is there an easy way to have your Linux clients use AD for user login authentication? I have a lot of CentOS servers and would like to have AD authentication so my regular administrators can just use their AD accounts to login without having to keep a separate account on each Linux server, also this will help with the password policies we have in place. I would also like something than can send authentication events to our Splunk indexer like the Windows logon success and failure, 4624 and 4625 events.

I know this can be done but I am looking for something simple to quickly setup on a lot of servers, like a simple rpm you install then a single config file you can fill in with your AD information, restart the service and you are up and running.

Do you authenticate your Linux users with AD and how?

88 Upvotes

55 comments sorted by

28

u/[deleted] Oct 20 '12

I tried this- https://help.ubuntu.com/10.04/serverguide/likewise-open.html for home lab. Worked like a charm.

3

u/justFen @justFen_ Oct 20 '12

We use this for our Linux boxes within our Windows Environment.

Was pretty easy to get set-up and running, may run into a few issues with file permissions which we resolved pretty easily.

1

u/gospelwut #define if(X) if((X) ^ rand() < 10) Oct 20 '12 edited Oct 20 '12

How did you setup your SSH to interact with AD logins? Can you restrict it by OU/etc?

EDIT: Hm. Probably /etc/security/pam_winbind.conf

3

u/justFen @justFen_ Oct 20 '12

Not at work right now, will update this comment on Monday morning if you still need help.

Off the top of my head, I added a certain administrator AD group to a group on the Linux boxes.

0

u/[deleted] Oct 20 '12

[deleted] — view deleted comment

1

u/gospelwut #define if(X) if((X) ^ rand() < 10) Oct 20 '12

Does it map out each AD group to OU or something? Or is that configured manually?

2

u/[deleted] Oct 20 '12 edited Oct 20 '12

/etc/ssh/sshd_config by itself does no more then check users or groups defined in the Allow\DenyUsers or Allow\DenyGroups (repectively) fields are correct for the user logging in via SSH.

I don't know how Likewise Open represents users or groups but I can assume that it's something like what your would find in /etc/ldap.conf, /etc/openldap/ldap.conf, or /etc/nslcd.conf. Some variation of this is usually what you see in examples on how to tell the Linux server where to look in whatever LDAP for user or group information.

For RHEL 5, /etc/ldap.conf will have lines like this:

nss_base_passwd         ou=users,dc=test,dc=internal?sub?objectClass=user
nss_base_shadow         ou=users,dc=test,dc=internal?sub?objectClass=user
nss_base_group          ou=groups,dc=test,dc=internal?sub?objectClass=group

That tells the server that, for user objects in the DC.INTERNAL domain, it should start in the ou=users,ou=test OU. Same thing for groups. Those values - if properly configured - will be passed as POSIX-compliant values that /etc/ssh/sshd_config will use to allow or deny.

Likewise Open may use a setup like this but what\where it is I do not know.

The reason that you set these is to prevent the server from having to query your entire LDAP everytime an authentication (or other LDAP-related) event occurs. Linux isn't 'that' bad about it but I have some AIX servers that absolutely refuse to work unless they are given the exact DN.

Some attempts to resolve this exist. Not sure about Debain or Ubuntu but on RHEL and RHEL-clones, the /etc/nscd.conf and ncsd service will do what they it does; cache name services results. This can cause problems if your TTL values for your LDAP-related queries are too high. To point is, though, to reduce the number of direct LDAP queries the server has to make to the LDAP server(s). I have read many people suggesting to just turn nscd off completely and I recommend it as well for small(er) environments and when testing.

Hope this clears up how sshd determines what groups or users are to be applied to the Allow\DenyUsers and Allow\DenyGroups values in /etc/ssh/ssh_config.

Hopefully, someone with more Likewise Open experience can confirm or correct this.

EDIT: So many spelingz and grammerz problems today...

2

u/gospelwut #define if(X) if((X) ^ rand() < 10) Oct 20 '12

They helps a lot and is along the lines of what I suspected. I also very much appreciate the caveats.

0

u/[deleted] Oct 20 '12

[deleted] — view deleted comment

1

u/gospelwut #define if(X) if((X) ^ rand() < 10) Oct 20 '12

I wasn't really attached to OU, was just a bad example.

3

u/_churnd DevOps Oct 20 '12

It's been since acquired by BeyondTrust & is called PBIS open. I've used it on a few boxes in the past & it works great. Main thing I like about it is UID/GID's stay the same across boxes, which is great in unixland. SAMBA/Winbind doesn't do that I believe.

6

u/lebean Oct 20 '12

Winbind does it with idmap_rid configured, basing uid/gid off of the SID so they're the same across every samba instance.

1

u/_churnd DevOps Oct 20 '12

Dammit I knew it was possible. :(

1

u/cyclepathology Oct 20 '12

Winbind does it with idmap_rid configured, basing uid/gid off of the SID so they're the same across every samba

That's really cool. If I were building an environment from scratch (no old UIDs to consider) that's the way I'd go. If you've got thousands of existing accounts, Quest and Centrify offer tools to pull the old UIDs into AD and preserve the old UIDs and GIDs. Of course you pay for that.

2

u/packysauce Linux/Windows Admin Oct 20 '12

You can script the import then use idmap_ad and schema_mode sfu or rfc2307

1

u/cyclepathology Oct 20 '12

That's a good answer for keeping everything free.

If that were my top priority, I'd consider it. It's been a long while since I've done this, but it seems like going with rfc2307 or the SFU schema mode created additional containers and definitely additional attributes in AD that had to be maintained. The details depend upon which version of AD you're talking about, but either way places additional demands on AD maintenance. Since my help desk is responsible for adding/maintaining accounts and Quest had a pretty GUI that hid the murky details from them, that was what we recommended.

I might be wrong, but I assumed that the winbind/idmap_ad solution that calculates UIDs from SIDs requires smaller changes to AD. I'm assuming a lot here, such as defaults that tell the system where home directories are stored, default shells to use, methods of overriding the defaults etc. So I might be making unfounded assumptions about the simplicity of winbind/idmap_ad with no legacy considerations. If you have any thoughts on that subject, I'd be interested in learning about them.

Another solution would be to have enough qualified people on staff who understand maintaining Unix attributes in AD that doing so is a nonissue. That's not the world I live in. Buying software that hides the details is cheaper than hiring qualified people, or so I am told. Sometimes I believe that, sometimes I do not.

2

u/packysauce Linux/Windows Admin Oct 21 '12

Thanks for taking the time to give such a thought-out response!

The additional load on Active Directory is minimal. Depending on AD version, no schema change as required as SFU has been deprecated and rfc2307 has been included for a while now.

Overall, I recommend idmap_rid for new deployments and situations where the unix file permissions aren't that pervasive. For situations where there are extensive unix ID setups in place and folks are looking to migrate, I recommend using idmap_ad as you can import from your existing management scheme.

In the smb.conf there are methods for setting up sensible defaults such as "winbind template homedir" and "winbind template shell". I'm unsure of what idmap backends these work with and if they work with idmap_ad properly. But, hey, at least they're there, right?

There is a cute GUI interface for people used to working with ADUC on the properties page of users and groups. It shows up as "UNIX Attributes" and has a selectable NIS domain as well as UID/GID, homedir, and shell.

Once you have the heavy lifters get the backend straightened out, the help desk knowledge update is pretty minimal. It's been a while since I've actually bothered with it (running idmap_rid, here) but I believe that AD will keep track of UID/GID for you and won't suggest an already-taken UID/GID

1

u/cyclepathology Oct 21 '12

Thanks, that's good information. It's been several years since I've tried native Linux/AD integration. Sounds like it's time to hit the lab and try it out again.

Again, thanks for the insightful responses.

17

u/[deleted] Oct 20 '12

I have AD authentication working beautifully with CentOS using winbind and SAMBA, doing exactly what you want. Admins log in with domain credentials, and through AD group memberships get access to use sudo. It's actually not that difficult. Here's one walkthrough, there are tons of other ones:

http://wiki.centos.org/TipsAndTricks/WinbindADS

Once you have winbind working and seeing your AD users and groups, you can use an AD group just like a local UNIX group, including defining file permissions and within config files like sudoers. The only caveat is some programs don't like spaces in the group names in their config files. So you might need to rename and create some new groups in AD.

11

u/acleverpseudonym Oct 20 '12

If I can just add something to this post, one other thing that you need to be aware of when doing this is that by default, UID and GID numbers for the AD users and groups will not by synchronized from Linux system to Linux system. This can cause problems if you want to, say, rsync -av files between 2 of the systems and have the ownership stay the same.

There are many solutions to this, but the easiest is to use the idmap_rid module. This is the easiest solution to this if you're just using a single domain. If you have complicated trust relationships set up and need to have users from multiple domains logging in, there are other solutions.

Using the idmap_rid module adds a couple lines to your smb.conf and makes it so that UIDs and GIDs of AD users and groups are derived from their SIDs using a consistent algorithm and are therefore the same on all systems without needing to install Unix Services for AD or maintain Unix attributes in AD.

5

u/tris10335 Network Engineer Oct 20 '12

This is the way I've always done it. Configure smb.conf with your domain and domain controllers and then do a net adsjoin -u and type in a domain user account that has join rights. It should prompt you for a password and done.

1

u/Julian702 Oct 20 '12

+1 internets

1

u/packysauce Linux/Windows Admin Oct 20 '12

Also you can set winbind normalize names that lowercases everything and replaces spaces with underscores.

8

u/[deleted] Oct 20 '12

Is there an easy way to have your Linux clients use AD for user login authentication?

Yes. Use samba\winbind. Or use Kerberos\LDAP through OpenLDAP and mapped to Active Directory and a Kerberos server or straight to Active Directory. Use FreIPA and bridge to Active Directory. You have lots of options. Purchase Quest Authentication Services (now owned by Dell) or Centrify. Use or purchase Likewise Open.

I have a lot of CentOS servers and would like to have AD authentication so my regular administrators can just use their AD accounts to login without having to keep a separate account on each Linux server, also this will help with the password policies we have in place.

You will find that, based n what solution you go with, that maintaining anything close to a unified password policy will require more then simply ensuring that Linux users can authenticate against Windows. You are already in the trap of "make Linux work like Windows" versus "make Linux work with Windows". You want the latter but I understand that 9 out of 10 times management wants the former.

I would also like something than can send authentication events to our Splunk indexer like the Windows logon success and failure, 4624 and 4625 events.

I you want and\or need accurate and clear "this user logged in to this server at X" (4624) or "this user failed to authenticate against from this server X at this time" (4625); then you are going to want to use a solution that leverages Kerberos and a solution that uses LDAP 2307 schema attributes to define user obejcts. things like uid, uidNumber, gid, unixHomeDirectory, etc. Windows Active Directory 2008 R2 supports these natively. Your solution should leverage them or you're going to have some difficulty in mapping uid to actually user...I'm looking at you samba.

I know this can be done but I am looking for something simple to quickly setup on a lot of servers, like a simple rpm you install then a single config file you can fill in with your AD information, restart the service and you are up and running.

Like that saying goes; fast, good, cheap...pick two. Some solutions are easier than others; that's for sure. You need to figure out what it is you actually want to or need to accomplish.

Here's my solution. A lot of people don't care for it because right now it's manual, requires that you tinker with your user and group objects in Active Directory or know how to use ldifs and\or csvde effectively to make bulk-user changes, it has a lot of steps and steps are hard, it doesn't use samba\windbind (because my solution specifically required getting rid of a poorly implemented samba\winbind solution), and, last but not least, it has it's own share of errors and less then clear objectives. But the biggest reason that people don't like it is because it has too many steps. Steps are hard, wrong is better :).

Configuring Red Hat Enterprise Linux (RHEL) 5 To Authenticate Against LDAP (Microsoft Windows Active Directory 2008 R2) Using Kerberos 5

I'm actually in the process of scripting this solution but, right now, it only supports RHEL 5 and RHEL 5 clones. My scripted version also supports autofs maps from LDAP configuration as well now. Requirements. They matter.

My point is not that you use my solution, rather, that you figure out what your requirements really are and find or create a solution that achieves them. I would really suck to buy a solution and find out it didn't do what you needed or, worse, that you could have accomplished the same thing for no cost other than your time.

There are lots of solutions out there. Look at them all, consider your requirements, and put something together that does what you need it to do.

1

u/misterkrad Oct 20 '12

do you also do ADFS 2? I've found there seems to be a lot of bugs in ntlm1->ntlm2 -> kerberos -> ADFS1/2 in open source.

1

u/[deleted] Oct 20 '12

I don't have any experience with this, unfortunately. I can't imagine, though, it would involve more then defining additional Kerberos realms in /etc/krb5.conf...but, like, I said, I don't have any experience there :). but so long as a trust exists between the two realms and that the two realms are defined...profit?

I'll add this to my list of things to get frustrated about.

Do you have any links to examples online that I could look at now?

1

u/misterkrad Oct 20 '12

http://onlinehelp.microsoft.com/en-us/office365-enterprises/ff652539.aspx

some php code showing login via live.com to get a token , it's pretty readable. I'm actually having a hard time reversing it back to NTLM since I do not wish the burden of ADFS 2.0 (buying a *.domain.com cert) etc.

http://code.google.com/p/php-dynamics-crm-2011/source/browse/branches/RB-1.0.2/RB-1.0.0/DynamicsCRM2011_Connector.class.php

2

u/[deleted] Oct 20 '12

Out of my depth here. Sorry, man, I'm still riding my Python bike with training wheels.

5

u/[deleted] Oct 20 '12

http://www.quest.com/authentication-services/ I'm sure its really expensive but we have a ton of servers, there is some setup on AD side as well but i don't handle that part.

1

u/smogger77 Oct 20 '12

Its actually not that expensive. We bind macs and Linux (fedora &ubuntu) to the domain.

1

u/cyclepathology Oct 20 '12

"Expensive" is one of those words where the meaning changes depending upon perspective. Both Centrify and Quest offer a sliding scale of capabilities that allow all sorts of neat things. Basic authentication started at around $400 per server.

4

u/TwistedStack Oct 20 '12

This only works on CentOS/RHEL and derivatives:

/usr/sbin/authconfig --enablekrb5kdcdns --enablekrb5realmdns --smbworkgroup="EXAMPLE" --enablewinbind --enablewinbindauth --smbsecurity=ads --smbrealm="EXAMPLE.COM" --smbidmapuid="10000-20000" --smbidmapgid="10000-20000" --winbindtemplateshell="/bin/bash" --enablewinbindusedefaultdomain --enablewinbindoffline --winbindjoin="Administrator" --enablecache --enablemkhomedir --update

3

u/randomfrequency Head -> Desk Oct 20 '12

Check out the FreeIPA project.

There's an authentication component to AD that involves blasting domain passwords around, it won't be 'fast'.

2

u/Jimbob0i0 Sr. DevOps Engineer Oct 20 '12

3.0 just came out on F18 (and hopefully rhel6.4 soon) that has a proper trust relationship with an AD domain rather than the password sync mechanism in 2.1/2.2

3

u/Cidan Oct 20 '12

yum -y install sssd

authconfig --enablesssd --enablesssdauth --ldapserver=yourldap-server.com --ldapbasedn=dc=base,dc=yourldap-server,dc=com --disableldaptls --updateall

chkconfig sssd on

Edit /etc/sssd/sssd.conf so it looks something like this:

[domain/LDAP]

id_provider = ldap

auth_provider = ldap

ldap_schema = rfc2307

ldap_uri = ldap://yourldap-server.com,ldap://yourldap-server2.com

ldap_search_base = ou=People,dc=yourldap-server,dc=com

ldap_user_search_base = ou=People,dc=yourldap-server,dc=com

ldap_group_search_base = ou=Groups,dc=yourldap-server,dc=com

ldap_tls_reqcert = allow

cache_credentials = true

enumerate = true

entry_cache_timeout = 5400

ldap_network_timeout = 3

ldap_search_timeout = 3

ldap_enumeration_search_timeout = 10

ldap_opt_timeout = 3

dns_resolver_timeout = 1

Then restart sssd:

service sssd restart

And you're done. Works on both RHEL5 and 6 (and all clones, CentOS, SL, etc).

2

u/problemforme Oct 20 '12

We do it. I'm not sure how; I'll have to check with our Linux admin and get back you.

2

u/zuzuzzzip Oct 20 '12

First I used Likewise Open. But I stopped using it once some company acquired it. I started getting loads of junk mails because of this. Also it did not work perfectly and was third party software.

I now use Winbind, which relies on Samba and it is much easier to setup. I have a CLI one-liner to join a linux box to Active Directory. In CentOS and Red Hat you can do this with the authconfig command.

btw: I use CentOS (some RHEL documentation here)

2

u/musicalvegan0 Oct 20 '12

I use SSSD. It's worked great so far in my Windows+CentOS+Ubuntu environment.

SSSD takes everything into consideration when allowing you to authenticate with AD.

You may just be asking for login authentication, but with that comes a lot of other behind the curtains things a user doesn't normally think of. For example, UID to AD ID sharing/independence. Home directory and shell configuration. Group membership. SSSD allows you to configure all of that on the Linux side, but also is compatible with Windows' SFU package if you choose a more AD-inclusive approach.

SSSD is the easiest all-in-one solution. You can do other things though, like Samba+Windbind and LDAP/S+KRB5. These other solutions are proven in production but offer tougher configuration.

Good luck!

1

u/UnoTaco Linux, Windows, Infrastructure Engineer Oct 20 '12

Not exactly super easy but most can be set up with system-config-auth. Use winbind + krb5. Use AD idmap back end, install Unix identity services on your DCs. It's as simple as 'net ad join -U username' once your configs are setup.

1

u/[deleted] Oct 20 '12

Is there an easy way to have your Linux clients use AD for user login authentication?

We use vintela for Solaris, and Linux AD logins - http://www.quest.com/authentication-services/

It is, I'm told, not cheap. But it is one of those things that just works well.

1

u/tehphr4nk Nix Admin, VCP5, RHCSA Oct 20 '12

We have a ldap server that points to our domain controller then Configure our servers for LDAP authentication.

1

u/alsimone Oct 20 '12

Kerberos is ready to set up. Only one config file and it's not complicated. Don't even need to restart anything.

I'd look at LDAP for authorization. Also check out pam_mkhomedir.so.

1

u/Tr0l Security Admin Oct 20 '12

I am interested in the same thing but, I need AD usernames to be mapped to different Linux usernames. One of our applications is in COBOL and the permissions for the application are directly related to the first letter in a username (currently A, B, or C). Is there a way to have the Linux server authenticate through AD but assign a specific Linux username to each AD account?

1

u/macjunkie SRE Oct 20 '12

We used to use Pam SMb, now we just shove passwords to our Linux hosts from our Idm system when a user changes their password or is provisioned

1

u/shinta148 Sr. Engineer, IT Security Oct 20 '12

Likewise Open rocks. We use it for our Linux Environment (mix of CentOS and Ubuntu workstations) and we have the full fledged power broker enterprise for our Macs.

Love it.

1

u/sakodak Oct 20 '12

Others have mentioned, but look into FreeIPA. It's incredibly easy to set up and it's Linux/Unix native, allowing you to do some things that a simple auth against AD can't:

  • Host based access control (HBAC) -- don't want your devs on prod boxes? Use this.
  • Centralized sudo control using HBAC -- set up your sudo rules in one place. This isn't an option with AD.
  • Unix native command line tools for administration (there's a web based GUI as well.)

As others have said, with version 3 (which is out now) you can set up a domain trust between your AD and IPA kerb realms, so you get SSO across the board, with the benefits that IPA brings to the table.

1

u/[deleted] Oct 20 '12

Joining domains with samba just for logins? Christ, what overkill! Dude, ignore all that nonsense you're told about that. And anything about likewise etc. Install Unix extensions on AD for one thing, then configure ldap.cibf or nskcd.conf for user info lookups. Then use either simple kerberos od the same ldap configuration to authenticate. I suggest ldap and nothing else, but standalone kerberos is pretty easy. You shouldn't need to install ANYTHING extra at all.

DON'T USE SAMBA TO JOIN THE DOMAIN. OVERKILL!

I would also recommend using puppet to deploy these configuration as it's an excellent tool in general.

1

u/BitingChaos Oct 20 '12

Our server: Windows Server 2003 R2 (x64)

Our clients:

  • CentOS 6.3
  • Ubuntu 12.04
  • Ubuntu 10.04
  • FreeBSD 9.0
  • Mac OS X (10.5/6/7/8)

It's pretty simple. We just use LDAP + Kerberos. Kerberos is dead simple to set up ("it just works"). I had to use slightly different LDAP configs on each platform (FreeBSD & Ubuntu use a similar config, CentOS uses a slightly different "SSS" method). You can then edit the appropriate pam.d config to allow local login.

Users can SSH in or use NFS shares. Windows stores their UID, GID, Shell, Home, etc. We can manage permissions directly on the clients. Users can change their password direct from the clients as well. All users are seen as local accounts.

For CIFS, I use Winbind+Kerberos. Users get their correct UID/GID vis rfc2307 and so the CIFS permissions match the NFS permissions perfectly (we do not use Winbind for local login, only SMB/CIFS access).

1

u/[deleted] Oct 20 '12

Linux to AD? I've seen Windows to LDAP done via PGina before, but not the other way around.

1

u/mingaminga Oct 21 '12

As a pentester, I applaud this idea. I love knowing that your Linux boxes will be immediately 0wnable.

0

u/[deleted] Oct 20 '12

[deleted] — view deleted comment

2

u/[deleted] Oct 20 '12

We use Centrify and I love it. Works perfectly, we have 15 RHEL servers on each network and I can change my password on one domain controller and be done. Still working out user management but I'm sure we will get it.

2

u/eggbean Oct 20 '12

I use it with Debian based distros.

2

u/punkwalrus Sr. Sysadmin Oct 20 '12

I used Centrify for a number of years at a previous job. Here's some problems we ran into:

  1. Their caching was using up huge amounts of resources. As in GB's of drive space, half the RAM, and on certain systems, this froze them. It was so bad on our mail tagging servers, running ClamAV+Spamassassin, we had to remove it. Their techs tried everything to fix it, and the only "fix" was deleting the cache through a cron job, which messed up authentication randomly.
  2. Their caching did not update properly 100% of the time. I mean, it worked MOST of the time, but randomly it did not. Deleting the cache and/or restarting the system was the common fix, but it was inelegant.
  3. The Windows side of the service did NOT take to AD load balancing or moving Domain Controllers very well, but part of that problem was the CTO kept changing shit around; adding, removing, renaming ADCs constantly. Part of me thinks if we just left it alone, it would have been fine. But we could only have one DC at a time, and then porting it to a new one was so horrible, the Centrify folks often told us to just delete and reinstall it as a new service, and import the accounts.

BUT, that was 5 years ago. Centrify may have fixed this by now. And I will add that their techs were really doggedly trying to fix these problems, as in they were excellent support that were not satisfied shit wasn't working. I felt guilty telling them "thanks, but no thanks" when we dropped the service because they tried so hard to get everything to work, and otherwise seemed technically competent and helpful.