Squid NTLM authentication configuration using ntlm_auth

Q. How do I configure squid for NTLM authentication?

A. You need to use squid ntlm_auth helper tool. It o allow external access to Winbind's NTLM authentication function. ntlm_auth uses winbind to access the user and authentication data for a domain.

Make sure winbindd is working

winbindd is a daemon that provides a number of services to the Name Service Switch capability found in most modern C libraries, to arbitary applications via PAM and ntlm_auth and to Samba itself. If you are not sure about winbindd, refer to official Samba documentation for configuration.

Configure squid for NTLM authentication

Open squid configuration file - squid.conf, enter:
# vi squid.conf
Append following configuration directive:
auth_param ntlm program /usr/lib/squid/ntlm_auth --helper-protocol=squid-2.5-ntlmssp
auth_param basic program /usr/lib/squid/ntlm_auth --helper-protocol=squid-2.5-basic
auth_param basic children 5
auth_param basic realm Squid proxy-caching web server
auth_param basic credentialsttl 2 hours

To setup ntlm_auth for use by squid 2.5 with group limitation, add:
auth_param ntlm program /usr/lib/squid/ntlm_auth --helper-protocol=squid-2.5-ntlmssp --require-membership-of="WORKGROUP\Domain Users"
auth_param basic program /usr/lib/squid/ntlm_auth --helper-protocol=squid-2.5-basic --require-membership-of="WORKGROUP\Domain Users"
auth_param ntlm children 5
auth_param ntlm max_challenge_reuses 0
auth_param ntlm max_challenge_lifetime 2 minutes

OR You can also pass DOMAIN/PDC name:
auth_param ntlm program /usr/lib/squid/ntlm_auth DOMAINNAME/PDC
auth_param ntlm children 5
auth_param ntlm max_challenge_reuses 0
auth_param ntlm max_challenge_lifetime 2 minutes

Now add ACL configuration for ntlm_auth helper
acl ntlm_users proxy_auth REQUIRED
http_access allow ntlm_users
http_access deny all

Save and close the file. Restart Squid:
# /etc/init.d/squid restart
For more information:

Updated for accuracy.

Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!

{ 13 comments… read them below or add one }

1 Tapan Shah 04.09.07 at 9:30 am

I am getting an error while configuring this the error is

FATAL: authparam basic program /usr/bin/ntml_auth: (2) No such file or directory
Squid Cache (Version 2.5.STABLE6): Terminated abnormally.
CPU Usage: 0.007 seconds = 0.002 user + 0.005 sys
Maximum Resident Size: 0 KB
Page faults with physical i/o: 0
Aborted. so do reply me about this
Thank you.

2 nixcraft 04.11.07 at 6:20 pm

Set correct path for /usr/lib/squid/ntml_auth file

3 jayaram 07.27.07 at 11:09 am

How can l block one Active directory user to access internet through squid ( or blank password users)

4 dark_harmonics 09.11.07 at 12:32 am

If you are getting error its because the author messed up his script. Check for where he substitues ntml instead of ntlm. Fix that and you are good to go!

5 vivek 09.12.07 at 5:01 am

dark_harmonics,

The FAQ has been updated. I appreciate your feedback.

6 deepak ray 09.20.07 at 6:28 am

Good work
and we have to share our experiences and idea

to all Linux worker

7 samerk 10.25.07 at 1:35 pm

thank you guys for this documentation it’s quite helpful when configuring Squid with NTLM.
However i have a couple of questions regarding clients that are not joined to the Active directory DC:

1- a NON-joined client using IE will have to log on using realm/username and passwd. Is there a way to make him authenticate with only his username and passwd ?
NB:It works fine with other browsers such as Firefox.

2- If you use IE with this NTLM auth (on an NON-joined pc) and select the ’save password’ checkbox the password gets stored in the registry as if it was for a network location. To delete the record you will have to run
“rundll32.exe keymgr.dll, KRShowKeyMgr”
This is causing real problems to users. Have you encountered this? and were you able to figure a way out?

Thanks again,
Samerk

8 newbie 06.11.08 at 1:15 pm

i have two groups one group has only access to whitelist and another group have full access to internet. how can i setup squid to autorizate groups

9 matu 08.13.08 at 1:11 pm

For squid 2.6, see the following Wiki page.
I was able to start squid only after configuring squid.conf as described there.
http://wiki.squid-cache.org/ConfigExamples/WindowsAuthenticationNTLM?highlig%20ht=%28ConfigExamples%29

10 matu 08.13.08 at 1:30 pm

one more thing, on the above wiki page there is a ownership fix by using “cache_effective_group root” in squid,conf. It worked for me only after removing this line from squid.conf. so do not add it to squid.conf.

11 James Johnston 10.30.08 at 4:54 am

To deal with winbind permissions problems:
(1) add proxy user to winbindd_priv group. (2) comment the “cache_effective_group” line in squid.conf so that secondary groups for the proxy user aren’t ignored.

Once I did that NTLM worked fine.

12 sameer kale 04.05.09 at 8:22 am

I want to authenticate the user by his username , password and MAC address.. Is it possible by ntlm_auth??? How?

13 bala 05.31.09 at 8:42 am

Hi I am able to configure NTLM with squid.It works great.
But i use Dansguardian for content filtering.With this setup (DG+SQUID+NTLM) ,things works fine for a user logged in to the domain.But for a local user it does not fall back to the basic program and i get a access denied page (as unauthenticated user fall to filter group 1 in DG)
Any help

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Tagged as: , , , , , , ,

Previous post: Find files by access, modification date under Linux or UNIX

Next post: Restrict certain users log onto a system via SSH server