Leif160519的blog Leif160519的blog

——————

目录
Squid设置用户名密码
/    

Squid设置用户名密码 置顶!

在ubutnu上设置squid代理认证
为了在Ubuntu上设置Squid代理身份验证,您需要对Squid配置文件进行以下一些调整:

1.生成Squid代理身份验证密码

htpasswd是两种可用于生成代理用户身份验证密码的工具。虽然 htpasswd 加密密码并以混杂格式存储密码,但 htdigest 将密码存储在纯文本中,因此不安全。在此指南中,我们将使用 htpasswd 实用程序。htdigest
为了使用htpasswd,您需要安装。安装它:httpd/apache2-utils

sudo apt-get install apache2-utils
sudo yum install httpd-tools

安装后,运行下面的命令以生成密码供用户验证。

htpasswd -c /etc/squid/.squid_users amos
New password: 
Re-type new password: 
Adding password **for** user amos

这为用户amos创建一个密码,并将其存储在。/etc/squid/.squid_users

要添加更多用户,您需要从htpasswd命令中删除选项-c:

htpasswd /etc/squid/.squid_users john
New password: 
Re-type new password: 
Adding password **for** user john

当您检查密码文件时,现在有两个用户使用加密密码:

less /etc/squid/.squid_users
amos:**$apr1****$IyfTZICg****$2fPImX5o14XC2KPF1kZWv**/
john:**$apr1****$5o0XKeto****$m6c5B5KK5ZAK**/7A/VIgYB/

squid用户应该能够阅读此文件。因此,运行下面的命令以设置适当的权限:

chown squid /etc/squid/.squid_users

验证用户名和密码是否适用于squid代理。对于每一个正确的条目,您应该看到如下所示显示:OK

/usr/lib/squid/basic_ncsa_auth /etc/squid/.squid_users 
amos password
OK
john password
OK

2.配置Squid代理身份验证

由于一切似乎都很好,继续设置Squid代理基本身份验证。打开Squid配置文件进行编辑并添加以下行。

auth_param basic program /usr/lib/squid/basic_ncsa_auth /etc/squid/.squid_users
auth_param basic children 5
auth_param basic realm Proxy Authentication Required
auth_param basic credentialsttl 2 hours
auth_param basic casesensitive off

acl auth_users proxy_auth amos john
http_access allow auth_users

作为上面所述行的简要概述:

  • 第一行告诉Squid使用帮手程序,并在文件中查找用户名和密码。basic_ncsa_auth/etc/squid/.squid_users
  • 该线指定了生成Squid身份验证器过程的最大数量。auth_param basic children 5
  • auth_param basic realm指定要向客户报告身份验证方案的保护范围。
  • auth_param basic credentialsttl 2 hours指定Squid假定外部验证的用户名有多长:密码对适用于
  • auth_param basic casesensitive off指定用户名是否对案例敏感。
  • acl auth_users proxy_auth amos john为允许身份验证的用户定义Squid身份验证 ACL。
    完成配置后,保存文件并重新启动Squid。
    systemctl restart squid
    

终端实用代理的方法:

export http_proxy=http://username:passwrod@proxy_ip:proxy_port
export https_proxy=http://username:password@proxy_ip:proxy_port

3.参考

Squid设置用户名密码
Squid 配置带用户名、密码验证 代理服务器


“The first 90% of the code accounts for the first 90% of the development time. The remaining 10% of the code accounts for the other 90% of the development time.” – Tom Cargill

标  题Squid设置用户名密码
作  者Leif160519
出  处https://github.icu/articles/2021/11/27/1638001156905.html
关于博主:坐标南京,运维工程师,如有问题探讨可以直接下方留言。
声援博主:如果您觉得文章对您有帮助,可以评论、订阅、收藏。您的鼓励是博主的最大动力!