imlach

Linux Kerberos auth

Nov 9th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. Edit your /etc/krb5.conf with your Windows realm settings. It's probably enough to delete all the example domains and set lookup_kdc to true.
  2.  
  3. Edit your /etc/samba/smb.conf. Set
  4.  
  5. security = ads
  6. realm = <KRBREALMNAME.ORG>
  7. workgroup = <NBDOMAINNAME>
  8.  
  9. At the bare minimum. Also handy:
  10.  
  11. idmap uid = 10000-99999
  12. idmap gid = 10000-99999
  13. idmap config NBDOMAINNAME : backend = rid
  14. idmap config NBDOMAINNAME : range = 1000-9999
  15. template homedir = /home/%U #%U becomes whatever the username is
  16. template shell = /bin/bash #or whatevs, you know
  17.  
  18. Generates the UIDs and GIDs from the RIDs, but keeps them the same across linux boxes.
  19.  
  20. My personal additions:
  21.  
  22. winbind use default domain = yes
  23. winbind normalize names = yes
  24. winbind nested groups = yes
  25.  
  26. Normalize names means "Domain Admins" is now "domain_admins"
  27.  
  28. Hit it the config with a testparm -v and make sure it checks out before moving on.
  29.  
  30. Next you will need to actually join the domain, so run
  31.  
  32. net ads join -U <username>
  33.  
  34. ...and make sure all went well with the join.
  35.  
  36. Now we can get to the fun part. Start up winbind with service winbind start and check the output/logs for any weird errors or warnings you may want to clear up.
  37.  
  38. Check the machine's connection to the domain and information gathering:
  39.  
  40. wbinfo -t #checks the domain trust credentials
  41. wbinfo -u #dumps all the usernames, feelsgoodman.jpg
  42. wbinfo -i <username> #should see a passwd-like line indicating idmap works
  43.  
  44. If all that comes back like it's supposed to, you should be ready to add in AD-based authnz.
  45.  
  46. Now you can add "winbind" to nsswitch.conf and run
  47.  
  48. id <domain username here>
  49.  
  50. This should return a user with a UID that equals the last part of the user's SID (the RID) + 1000 (or whatever the start of your range is)
  51.  
  52. If it doesn't, check to see if nscd is enabled and running, if so, issue a service nscd stop and run the 'id' command again.
  53.  
  54. If you get back the right stuff from id, you can enable pam_winbind. How, you ask? Should I edit the files by hand? Nah, waste of time. Just run authconfig or authconfig_tui and flag Winbind as enabled. It's basically just boilerplate stuff anyway.
  55.  
  56. The real magic happens in /etc/security/pam_winbind.conf. Here you can set the good stuff
  57.  
  58. krb5_auth = yes #makes it so your user can grab a kerberos ticket on login, handy for CIFS
  59. krb5_ccache_type = FILE #save that kerberos ticket, instead of just check that you were able to get one (which is the default)
  60. require_membership_of = "AD group here" #makes sure the user belongs to this group to control access (handy for servers!)
  61. mkhomedir = yes #Create homedir on login. slick, right?
  62.  
  63. Now, my child, you can attempt to login to the box with an Active Directory username. The groups are real groups, too. So you can use them with sudo, even with spaces. A line from one of mine:
  64.  
  65. %Domain\ Admins ALL=(ALL) ALL
Advertisement
Add Comment
Please, Sign In to add comment