Squid proxy User authentication with ncsa_auth

ImageHello Friends,

Here I am going to share how  configure Squid to prompt users for a user-name and password by using a program called ncsa_auth .

You can use the htpasswd program that comes installed with Apache to create your passwords. Here is how it’s done:

Create the password file. The name of the password file should be /etc/squid/squid_passwd, and you need to make sure that it’s readable for All :-

[root@sahil ~]# touch /etc/squid/squid_passwd
[root@sahil ~]# chmod o+r /etc/squid/squid_passwd

Add a user-name called sahil(as example):

[root@sahil ~]# htpasswd /etc/squid/squid_passwd sahil
New password: 
Re-type new password:
Adding password for user sahil
[root@sahil ~]#

Find your ncsa_auth file using the locate command:-

[root@sahil ~]# locate ncsa_auth
/usr/lib/squid/ncsa_auth   <----- ncsa_auth file location
[root@sahil ~]#

Make Some changes in squid.conf , you need to define the authentication program in squid.conf, which is in this case ncsa_auth. Next, create an ACL named ncsa_users with the REQUIRED keyword that forces Squid to use the NCSA auth_param method you defined previously. Finally, create an http_access entry that allows traffic that matches the ncsa_users ACL entry. Here’s a simple user authentication example; the order of the statements is important: –

[root@sahil ~]# vim /etc/squid/squid.conf
# Add this to the auth_param section of squid.conf
#
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd

#
# Add this to the bottom of the ACL section of squid.conf
#
acl ncsa_users proxy_auth REQUIRED

#
# Add this at the top of the http_access section of squid.conf
#
http_access allow ncsa_users

Restart Squid Server:-

[root@sahil ~]# /etc/init.d/squid restart

Thats it.

Now No one can access Squid without username(sahil) and given password .

Thank You !!

Enjoy Linux-Ing 🙂 🙂 🙂

 

2 thoughts on “Squid proxy User authentication with ncsa_auth”

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top