Winbind NTLM Authentication configuration for squid and apache Source
Markdown source
1---2title: 'Winbind NTLM Authentication configuration for squid and apache'3date: '2010-07-02'4published_at: '2010-07-02T13:10:00.008+10:00'5tags: ['apache', 'ntlm', 'samba', 'squid', 'sysadmin', 'winbind', 'windows']6author: 'Gavin Jackson'7excerpt: 'Introduction We want squid and apache (running on SLES 11) to use Microsoft Active Directory NTLM authentication. This means that users who have logged into our windows domain will not have to enter t...'8updated_at: '2010-07-02T17:13:26.617+10:00'9legacy_url: 'http://www.gavinj.net/2010/07/winbind-ntlm-authentication.html'10---1112[](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvAYzhkQ5_PZKehC3YyL9h73fPvPGQKmBbikPajlCmYuf62-EHV6biyLzSKwbGsETRs9YkCqu5z3_BI-qonJ6swNWsejBFz6Vw0_2MnkelkXCBCvcZCWPUWKrITZlBCz4WmfVgUjlM6ZE/s1600/SquarePegRoundHole.jpg)1314Introduction We want squid and apache (running on SLES 11) to use Microsoft Active Directory NTLM authentication. This means that users who have logged into our windows domain will not have to enter their user credentials to use these services. Package installation1516Install the following packages:1718```19samba20samba-winbind21apache2-mod_auth_ntlm_winbind (for apache)22```2324Samba Configuration Samba configuration (/etc/samba/smb.conf):2526```27[global]28workgroup = LESMILLS29passdb backend = tdbsam30security = ADS31realm = lesmills.net.au32password server = fs.lesmills.net.au33encrypt passwords = yes34winbind separator = \\35idmap uid = 10000-2000036idmap gid = 10000-2000037winbind enum users = yes38winbind enum groups = yes39winbind use default domain = yes40template shell = /bin/false41template homedir = /home/winnt/%U42allow trusted domains = no43```4445Next, you need to bind the Linux host to the windows domain:4647```48root# net ads join -U Administrator%password49```5051Modify /etc/nsswitch add the following line:5253```54passwd: files winbind55```5657Restart winbind and samba and you should be able to run getent passwd (you should see the AD users come back). Before modifying squid and/or apache you can test that ntlm_auth is working by typing:5859```60/usr/bin/ntlm_auth --username gavinj --domain=lesmills.net.au6162password:63NT_STATUS_OK: Success (0x0)64```6566This is a good sign that the system can talk to your AD server. Squid Add the following lines to your /etc/squid/squid.conf:6768```69auth_param ntlm program /usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp --domain=lesmills.net.au70auth_param ntlm children 571auth_param ntlm keep_alive on72```7374Apache7576```77zypper install pam_smb78setfacl -m u:wwwrun:rx /var/lib/samba/winbindd_privileged79a2enmod auth_ntlm_winbind80rcapache2 restart81```8283Add the following directives to your Directory entry:8485```86AuthName "NTLM Authentication thingy"87NTLMAuth on88NTLMAuthHelper "/usr/bin/ntlm_auth --domain=lesmills.net.au --helper-protocol=squid-2.5-ntlmssp"89NTLMBasicAuthoritative on90AuthType NTLM91require valid-user92```9394Note, to check that a user belongs to a specific AD group, you can use the following entry (it took me an hour to figure out the correct DOMAIN\\\GROUP syntax).9596```97AuthName "NTLM Authentication thingy"98NTLMAuth on99NTLMAuthHelper "/usr/bin/ntlm_auth --domain=lesmills.net.au --require-membership-of=LESMILLS\\\IT --helper-protocol=squid-2.5-ntlmssp"100NTLMBasicAuthoritative on101AuthType NTLM102require valid-user103```104105Browser Testing This technique works over http under IE8 and Firefox 3.6.3 on Windows 2008 (Terminal Server). This technique does not work over https under IE 8 (get a 500 server error). It does however seem to work fine in Firefox 3.6.3.106107To white list ntlm servers in recent versions of Firefox (so that it doesn't ask for a username and password), you need to use about:config and edit the network.automatic-ntlm-auth.trusted-uris option (enter your webserver name). References108109- [http://en.wikipedia.org/wiki/NTLM](http://en.wikipedia.org/wiki/NTLM)110- [http://blog.netnerds.net/2009/10/enable-windows-ntlm-pass-through-authentication-in-linux-based-apache/](http://blog.netnerds.net/2009/10/enable-windows-ntlm-pass-through-authentication-in-linux-based-apache/)111- [ http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/domain-member.html#ads-member ](http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/domain-member.html#ads-member)112113114