10 月 242014
 

svn相关:

安装:

yum -y install mod_ssl mod_dav_svn httpd mod_dav

配置:

<Location /test>
  DAV svn
  SVNParentPath /data/svn1
  SvnListParentPath on
   AuthType Basic
  AuthName “Please login”
  AuthBasicProvider ldap
  AuthLDAPURL “ldap://192.168.7.1:389/ou=system-admin,ou=login,dc=test,dc=com”
  AuthLDAPBindDN “cn=admin,dc=test,dc=com”
  AuthLDAPBindPassword “test”
  Require valid-user
</Location>

/data/svn1 下 svnadmin create test  建个test的仓库,然后记得更改权限。然后就可以通过LDAP的认证去访问svn了。这里只涉及到认证没涉及到权限。

 

git相关:

git可以源码安装,可以参考另一个文章。https://www.hmouse.cn/?p=4202

配置:

[root@localhost git]# cat /etc/httpd/conf.d/git.conf
SetEnv GIT_PROJECT_ROOT /var/www/html/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git /usr/local/libexec/git-core/git-http-backend
<LocationMatch “^/git/test.git/.*$”>
        Dav On
        Options +Indexes +FollowSymLinks
        AuthType Basic
        AuthName “Git Access”
        AuthType Basic
        AuthName “Please login”
        AuthBasicProvider ldap
        AuthLDAPURL “ldap://192.168.7.1:389/ou=system-admin,ou=login,dc=test,dc=com”
        AuthLDAPBindDN “cn=admin,dc=test,dc=com”
        AuthLDAPBindPassword “test”

        Require valid-user
</LocationMatch>

在 /var/www/html/git 下 新建的git仓库 都可以通过 ladp的 ou=system-admin,ou=login,dc=test,dc=com 认证访问。

 

VPN:

pptpd 的整合:

参考url:

http://www.shencan.net/index.php/2014/04/29/freeradius-%E4%B8%8E-ldap-%E6%95%B4%E5%90%88/  

ldap+radius  整合  这篇文章说的比较靠谱点

http://www.linuxyunwei.com/2013/05/pptpfreeradiusldap%E5%AE%9E%E7%8E%B0vpn%E7%AE%A1%E7%90%86/comment-page-1/  

 

openvpn的整合:

参考url:http://www.shencan.net/index.php/2014/05/03/openvpn-%E4%B8%8Eldap-%E6%95%B4%E5%90%88/

以下是转载,我自己没有安装。以做备用:

#################################

最近各种ldap,各种vpn。。 上篇文章把ldap跟radius 整合起来了 ,这篇文章主要讲openvpn跟ldap集合,这里先说下

openvpn跟ldap结合的方式有多种

1.通过openvpn-auth-ldap模块实现直接与ldap交互

2.通过radiusplugin这个插件 与radius结合(radius最终还是去ldap去认证)

本文先采用的是第一种 ,等下搞搞第二种吧 因为上篇文章已经把radius跟ldap整合起来了 第二种应该比较简单了。

开始搞吧

因为这个整合 前提是 openvpn 跟 ldap服务都ok  才能整合

关于openvpn 这个就不多介绍啥了  服务端 yum安装就行 然后生成证书啥的 比较简单 网上也有很多例子(编译安装也行)

默认方式客户端的证书需要从服务端 生成好后 搞到客户端上

关于配置的话  服务端是server.conf   客户端是client.conf

关于ldap的话 上篇文件也讲过安装 简单配置啥的

我直接上我已经整合好的配置吧

openvpn的server.conf

1

最上面框框里面的不多说了

下面框框起来的就是通过调用openvpen-auth-ldap模块来实现与ldap交互的 后面的cn=%u 就是通过uid

最后怎么与ldap交互 就是看这个配置文件了 /etc/openvpn/auth/ldap.conf

这个文件跟上面的模块就是由openvpn-auth-ldap  rpm包提供的

看看ldap.conf 吧

1

这里只是一个简单的与ldap服务器起链接 查询的过程 ,我这里为了简单 就没采用TLS的方式 如果夸公网的话 还是建议采用TLS方式去查询

OK openvpn服务端配置就这些

再看看 客户端client.conf 配置吧

1

客户端配置就这些 比较简单 (因为走ldap了认证  就不需要客户端证书了)

下面我们来试试吧

看过上面的文章还知道我得ldap有cpis1-cpis20 个账号 下面我们来测试下

测试cpis20账号吧

1

看服务端日志

1

ok  cpis20没问题

测试个cpis21把   提示认证失败

我们上日志吧

1

OK 差不多整合ok了

第一种OK了  开搞第2种吧

安装插件先安装依赖

yum install -y libgcrypt libgpg-error libgcrypt-devel

wget http://www.nongnu.org/radiusplugin/radiusplugin_v2.1.tar.gz &&  tar fxz radiusplugin_v2.1.tar.gz  && cd  /root/radiusplugin && make

cp radiusplugin.so /etc/openvpn/  模块

cp radiusplugin.cnf /etc/openvpn/  配置文件

ok 我们先改下radiusplugin.cnf 配置文件吧

1

ok  我们再去改下server.conf 配置文件

1

加载新模块 (刚刚安装的)

ok 然后重启服务 就ok了  这个比较简单。。。

因为这种客户端需要单独安装,不便操作,故没有实际去实施

现在 来说说 pptpd的 验证使用:

参考url:

整合:http://www.linuxyunwei.com/2013/05/pptpfreeradiusldap%E5%AE%9E%E7%8E%B0vpn%E7%AE%A1%E7%90%86/comment-page-1/  

以上的整合可惜只能用未加密的密码:

下面是加密的密码的参考url:

http://blog.sina.com.cn/s/blog_92dc41ea0101rbm0.html

http://bbs.chinaunix.net/forum.php?mod=viewthread&tid=1214563

注意的是

[root@ldap ~]# grep -v ‘#’ /etc/raddb/modules/ldap  | grep -v ‘^$’

ldap {

server = “localhost”

identity = “cn=root,dc=verystar,dc=cn”

password = 此处为LDAP root的密码

basedn = “ou=Users,dc=verystar,dc=cn”

filter = “(uid=%{%{Stripped-User-Name}:-%{User-Name}})”

password_attribute = userPassword

ldap_connections_number = 5

timeout = 4

timelimit = 3

net_timeout = 1

tls {

start_tls = no

}

dictionary_mapping = ${confdir}/ldap.attrmap

edir_account_policy_check = no

keepalive {

idle = 60

probes = 3

interval = 3

}

}

红色的注意要添加,

还有 就是添加新属性的时候

解决办法:

# vi /etc/openldap/schema/inetorgperson.schema,在objectclass ‘inetOrgPerson’ 前新增:

attributetype ( 1.3.6.1.4.1.3317.4.3.1.66

NAME ‘radiusUserPassword’

DESC ‘radiusUserPassword’

SUP userPassword )

修改objectclass ‘inetOrgPerson’ ,把’radiusUserPassword’ 作为可选属性加入’inetOrgPerson’ 对象类:

objectclass  ( 2.16.840.1.113730.3.2.2

NAME ‘inetOrgPerson’

DESC ‘RFC2798: Internet Organizational Person’

SUP organizationalPerson

STRUCTURAL

MAY (

radiusUserPassword $ audio $ businessCategory $ carLicense $ departmentNumber $

···略···

)

修改/etc/raddb/ldap.attrmap,添加

checkItem  NT-Password  ntPassword #原有的
checkItem  NT-Password  userPassword #新增的

checkItem  NT-Password  radiusUserPassword #新增的

注意顺序不能反,顺序对了PPTP和OpenVPN能同时工作。

修改/etc/openldap/slapd.conf

database  bdb

access to attrs=userPassword,radiusUserPassword

by self write

by * auth

由于MD4/MD5密码容易被字典攻击破解,因此有必要保护密文不让人轻易获得,同时建议使用复杂密码。

这里http://book.51cto.com/art/201204/328699.htm可以看到不太复杂的密码能穷举出来。

重启slapd。

通过phpLdapAdmin添加时,一定要记得清缓存,否则会一直无法出现新属性。

由于无法整合2个验证,所以到时需要2个密码,一个是MD5加密的用来处理svn和git,一个是md4加密用来处理pptpd的认证。

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny