Socks5和HTTP代理实现PAM+OpenLDAP用户认证

来源:互联网 发布:织梦cms 地区分站 编辑:程序博客网 时间:2024/06/06 05:47

本文描述了Socks5代理SS5及HTTP代理Squid,通过PAM使用OpenLDAP完成用户认证的配置说明。

共分三部分,第一部分是PAM和OpenLDAP的配置;第二部分是在一的基础之上,如何配置SS5部分;第三部分是在一的基础之上,如何配置Squid部分。

第一部分是基础,二、三部分互相独立,但都需要基于第一部分的配置。


一、PAM + OpenLDAP的配置

配置前,需要在pam所在服务器安装OpenLDAP相关的client端工具。

yum install nss-pam-ldapd pam_ldap openldap-clients -y


##/etc/pam.d/authconfig 配置文件
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#%PAM-1.0
auth            include         config-util
account         include         config-util
session         include         config-util

##/etc/pam.d/config-util 配置文件
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

#%PAM-1.0
auth            sufficient      pam_rootok.so
auth            sufficient      pam_timestamp.so
auth            sufficient      pam_ldap.so
auth            include         system-auth
account         required        pam_permit.so
session         required        pam_permit.so
session         optional        pam_xauth.so
session         optional        pam_timestamp.so


##/etc/pam_ldap.conf 配置文件

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

# host 127.0.0.1 

# OpenLDAP server IP
host 192.168.71.100


# The distinguished name of the search base.
#base dc=example,dc=com
base dc=sinowel,dc=com

# The distinguished name to bind to the server with.
# Optional: default is to bind anonymously.
#binddn cn=proxyuser,dc=example,dc=com
binddn cn=admin,dc=sinowel,dc=com

# The credentials to bind with.
# Optional: default is no credential.
#bindpw secret
bindpw secret

# Filter to AND with uid=%s
#pam_filter objectclass=account
pam_filter objectclass=*

# The user ID attribute (defaults to uid)
#pam_login_attribute uid
pam_login_attribute uid

# Do not hash the password at all; presume
# the directory server will do it, if
# necessary. This is the default.

pam_password clear


二、SS5使用PAM+OpenLDAP的配置

##/etc/pam.d/ss5 配置文件

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


# SS5 Pam configuration file
#
#
# Authentication using ldap
auth        required    /lib64/security/pam_ldap.so


##/etc/opt/ss5/ss5.conf 配置文件
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

set SS5_CONSOLE
set SS5_PAM_AUTH
set SS5_AUTHCACHEAGE    600


# ///////////////////////////////////////////////////////////////////////////////////
#       SHost           SPort           Authentication
#
#auth    0.0.0.0/0               -               -
auth    0.0.0.0/0               -               u

# /////////////////////////////////////////////////////////////////////////////////////////////////
#      Auth     SHost           SPort   DHost           DPort   Fixup   Group   Band    ExpDate
#
#permit -       0.0.0.0/0       -       0.0.0.0/0       -       -       -       -       -
permit u        0.0.0.0/0       -       0.0.0.0/0       -       -       -       -       -

通过以上配置,SS5 Socks5代理使用PAM+OpenLDAP认证测试通过。


三、Squid使用PAM+OpenLDAP的配置

##/etc/pam.d/squid 配置文件
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

auth        required    /lib64/security/pam_ldap.so
account        required    /lib64/security/pam_ldap.so


##/usr/etc/squid.conf 配置文件

#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


#pam auth
auth_param basic program /usr/lib64/squid/pam_auth

auth_param basic children 5
auth_param basic realm Web-Proxy
auth_param basic credentialsttl 10 minute
auth_param basic casesensitive off

#acl config
acl pam_auth proxy_auth REQUIRED

#http access
http_access allow pam_auth
http_access allow localhost


注:以上,是对相关配置文件与PAM和OpenLDAP有关部分修改的说明,完整的配置文件不在此说明,可以参考网络或我其它文章的说明。

原创粉丝点击