Linux搭建使用LDAP协议认证的SVN服务器

来源:互联网 发布:股票智能分析软件 编辑:程序博客网 时间:2024/05/18 02:47

前言

公司近期需要迁移SVN服务器,并与Windows的活动目录集成,使用LDAP协议认证。


一、环境准备

        1、两台LInux服务器,我这里使用的是CentOS6.5的系统

        2、关闭SELINUX和防火墙

#修改selinux配置文件
# sed -i 's/SELINUX=enforcing/SELINUX=disablesd/g' /etc/sysconfig/selinux# reboot
#重启后生效,查看selinux状态# getenforce#查看防火墙运行状态# /etc/init.d/iptables status# chkconfig iptables off

二、安装SVN服务
#yum安装
# yum install subversion 
#查看安装位置# rpm -ql subversion#查看svn版本,如果有说明安装成功# /usr/bin/svnversion --verison#创建版本库# mkdir -p /opt/svn/repos# svnadmin create /opt/svn/repos#svn配置文件目录conf# cd /opt/svn/repos/conf
# vi passwd     #账号密码文件
   [users]
   user = 123456
# vi authz      #权限控制文件 
   [/]
   user = rw
# vi svnserve.conf          #服务配置文件

anon-access=read #匿名用户访问权限

auth-access=write #授权用户访问权限

password-db=passwd #指定账号文件,默认为conf目录下的passwd文件

authz-db=authz #指定权限文件,默认为conf下的authz文件

realm = /DATA_SVN/repos #认证域,为创建的版本库所在的目录

#配置完成后启动svn服务
# svnserve -d -r /opt/svn/repos --log-file /var/log/svnserve.log
    -d为后台运行
    -r指定版本库的目录
    --log-file 生成日志文件
#查看运行进程
# ps aux | grep svnserve

三、LDAP协议认证

用户访问svn服务器分成验证(passwd)和授权(authz)两个部分,svn本身内置了验证和授权机制(conf下的passwdauthz),默认使用明文,加密起来非常繁琐。

svn提供了对sasl的支持,从而用户的验证和授权有了更多的选择方式。

#安装Cyrus SASL相关组件# yum install –y subversion cyrus-sasl cyrus-sasl-lib cyrus-sasl-plain


#查看sasl版本和提供的验证模块信息# saslauthd -v


#修改SASL的用户验证方式为LDAP# cp /etc/sysconfig/saslauthd /etc/sysyconfig/saslauthd.save #保存配置文件# sed –I ‘s/MECH=pam/MECH=ldap/g’ /etc/sysconfig/saslauthd


#修改SASL的配置文件/etc/saslauthd.conf,如果配置文件不存在就新建一个# vi /etc/saslauthd.conf 填写ldap协议的各个要素ldap_servers:ldap://172.16.96.230 ldap_default_domain:miyaoa.comldap_search_base:OU=Employees_Accounts,DC=miyaoa,dc=comldap_bind_dn:miyaoa\svn.srv#ldap_bind_dn:svn.srv@miyaoa.com#ldap_bind_dn:CN=svn.srv,OU=Employees_Accounts,DC=miyaoa,dc=comldap_password:test.1234ldap_deref:neverldap_restart:yesldap_scope:subldap_use_sasl:noldap_start_tls:noldap_version:3ldap_auth_method:bindldap_mech:DIGEST-MD5ldap_filter:sAMAccountName=%uldap_password_attr:userPasswordldap_timeout:10ldap_cache_ttl:30ldap_cache_mem:32786#此处是填写的LDAP协议的各个要素

#重启SASL服务,测试配置文件是否正确,与AD连接能否成功# service saslauthd restart# testsaslauthd –u user –p password

提示“Success”说明配置文件正确,可以与AD连接成功。


#修改SVN的SASL配置文件/etc/sasl2/svn.conf,如果配置文件不存在就新建一个# vi /etc/sasl2/svn.confpwcheck_method:saslauthd #用户验证方法mech_list:plain loain #用户验证信息怎么传输

#修改版本库的conf配置# vim /opt/svn/repos/conf/svnservice.conf[general]#注释掉password-db = passwd[sasl]use-sasl=true #开启sasl用户验证

#重启SVN服务,测试一下# ps aux|grep svnserve查看进程号# kill –9 进程号# svnserve –d –r /opt/svn/repos




原创粉丝点击