LDAP
- openLDAP
- CentOS LDAP 配置
- 基本术语
o– organization(组织-公司)
ou – organization unit(组织单元-部门)
c – countryName(国家)
dc – domainComponent(域名)
sn – suer name(真实名称)
cn – common name(常用名称) - 基本命令
- 生成密钥:slappasswd –h {SSHA}
- 开启LDAP服务:/etc/init.d/ldap restart
- 查询用户:ldapsearch -x -LLL -b 'dc=<your domain>,dc=com'| more
- Apache+SVN+LDAP
配置 httpd.conf: <Location /svn> DAV svn # 指定此路径为使用DAV方式访问svn SVNParentPath /absolute/path/to/directory/containing/your/repositories # 包含所有版本库的路径,dav_svn模块支持访问多个svn版本库 SVNListParentPath on # 是否显示所有的版本库 #SVNPath /svndata/repos # 若只有一个版本库,那就直接配置此参数 # Authentication AuthType Basic # 使用基本的密码认证 AuthName "Your Subversion Repository" # 保护区域或”域”的名称 AuthBasicProvider ldap # 指定使用ldap验证用户 ## Active Directory requires an authenticating DN to access records ## This is the DN used to bind to the directory service ## This is an Active Directory user account #AuthLDAPBindDN “cn=someuser,cn=Users,dc=your,dc=domain” ## This is the password for the AuthLDAPBindDN user in Active Directory #AuthLDAPBindPassword somepassword ## The LDAP query URL ## Format: scheme://host:port/basedn?attribute?scope?filter ## The URL below will search for all objects recursively below the basedn ## and validate against the sAMAccountName attribute AuthLDAPURL "ldap://localhost:389/ou=users,dc=your,dc=domain?uid?sub?(objectClass=*)" # Authorization ## CASE 1: NO Group #Require valid-user # Require authentication for this Location ## CASE 2: SVN Group in LDAP Require ldap-group cn=svngroup,ou=somegroup,dc=your,dc=domain # 此授权仅为判断该用户是否可以访问svn服务 AuthLDAPGroupAttribute memberUid # 检查该Group下的memberUid看看是否存在该用户 AuthLDAPGroupAttributeIsDN off # 默认验证用户是否为组成员为使用DN,而通常做法是使用用户名,将该参数置成off,则使用用户名验证 # Subversion授权设置 AuthzSVNAccessFile /path/to/svn/authfile/authz # 指定路径授权文件 </Location> # 其他多种验证方式 Apache支持多种验证方式并存,如果你之前部署了基于文件的验证方式,那么最好的迁移方式是同时使用LDAP和FILE两种方式验证,优先使用LDAP,等你什么时候把文件用户迁移完,或者文件用户都无用之后,直接去除文件验证就OK了。 AuthBasicProvider ldap file # 指定使用ldap和file方式验证用户,优先使用ldap用户 AuthUserFile /path/to/authuserfile # 指定验证文件
- 配置vsftpd使用LDAP
编辑配置文件 /etc/pam.d/vsftpd,加入下面两行auth sufficient pam_ldap.so # 把这行放在第一个auth项 account sufficient pam_ldap.so # 把这行放在第一个account项
- 配置Linux用户登录使用LDAP
- 配置/etc/nsswith.conf
passwd: files ldap shadow: files ldap group: files ldap
- 打开System->Administration->Authentication图形界面来配
# /etc/sysconfig/authconfig USESYSNETAUTH=yes USESHADOW=yes USELOCAUTHORIZE=yes USELDAP=yes USELDAPAUTH=yes USEMKHOMEDIR=yes PASSWDALGORITHM=yes
- 配置/etc/sysconfig/authconfig
session required pam_mkhomedir.so skel=/etc/skel/ umask=0077 增加这个配置,使得每个用户目录不对其他用户开放
- 通过/etc/ldap.conf设置允许登录的用户组
pam_groupdn cn=server,ou=group,dc=vip,dc=com pam_member_attribute uniqueMember
- 通过LDAP Admin配置允许登录的用户组
添加 group of unique name 组至 ou=group,dc=vip,dc=com 可以在该组里添加被允许登录linux服务器的用户
- 通过LDAP Admin配置用户登录Linux后,在Linux系统中所属的用户组
1. 查询Linux系统中的group编号 2. 修改用户ldif中的gidNumber为相应的编号
- 配置/etc/nsswith.conf
- Advanced topic
- PAM的配置
# /etc/pam.d/system-auth,/etc/pam.d/vsftpd ## 认证鉴别接口类型 auth : 表示鉴别类接口模块类型用于检查用户和密码,并分配权限 account : 表示账户类接口,主要负责账户合法性检查,确认帐号是否过期,是否有权限登录系统等 session : 会话类接口,实现从用户登录成功到退出的会话控制 password : 口令类接口,控制用户更改密码的全过程,也就是有些资料所说的升级用户验证标记 ## Control_flag控制位 required : 表示该行以及所涉及模块的成功是用户通过鉴别的必要条件,只有当对应于应用程序的所有带required标记的模块全部成功后,该程序才能通过鉴别,如果任何带required标记的模块出现了错误,PAM并不立刻将错误消息返回给应用程序,而是在所有模块都调用完毕后才将错误消息返回调用他的程序。 requisite : 与required相仿,只有带此标记的模块返回成功后,用户才能通过鉴别。不同之处在于其一旦失败就不再执行堆中后面的其他模块,并且鉴别过程到此结束 sufficient : 表示该行以及所涉及模块验证成功是用户通过鉴别的充分条件。也就是说只要标记为sufficient的模块一旦验证成功,那么PAM便立即向应用程序返回成功结果而不必尝试任何其他模块 optional : 表示即便该行所涉及的模块验证失败用户仍能通过认证 include : 表示在验证过程中调用其他的PAM配置文件 ## module_path即所使用模块的全路径名称
- How to configure LDAP to access user account information: http://linux.web.cern.ch/linux/docs/account-mgmt.shtml
- Linux可插拔认证模块(PAM)的配置文件、工作原理与流程: http://www.infoq.com/cn/articles/linux-pam-one
- 鳥哥的 Linux 私房菜-Linux 帳號管理與 ACL 權限設定: http://linux.vbird.org/linux_basic/0410accountmanager.php#account_id
- PAM的配置
CentOS_5.6_配置Openldap_-_薛正华的专栏_-_博客频道_-_CSDN.pdf - CentOS LDAP 配置 (683 KB)
subversion_apache_ldap配置.pdf - Subverion+Apache+LDAP (407 KB)
回复 (1)
RE: LDAP - 由 范 益波 在 超过 7 年 之前添加
- 用Apache+SVN+LDAP的额外设置--svn 出现"Couldn't perform atomic initialization"
- 很大的可能是目前的SVN版本为1.6+ 而客户端版本则为1.6- http://snowing11812.iteye.com/blog/1703665
可采用以下命令重新创建repo 来实现兼容svnadmin create --fs-type fsfs --pre-1.6-compatible /path/to/svnrepo
- 有时候提示“ Can't open file '/opt/svn/test/db/txn-current-lock': Permission denied”
需要修改版本库目录权限chmod -R o+w /path/to/svnrepo
- 很大的可能是目前的SVN版本为1.6+ 而客户端版本则为1.6- http://snowing11812.iteye.com/blog/1703665