当前位置: 首页 > news >正文

通过ldap验证svn服务

1、简单介绍:

这里需要介绍一点的就是svn服务器的验证是需要通过SASL机制的,那么SASL全称为(Simple Authentication and security Layer),是一种用来扩充C/S模式验证能力的机制

SASL是一个胶合库,通过这个库把应用层与形式多样的认证系统整合在一起,这有点类似于PAM,但是后者是认证方式,决定什么人可以访问什么服务,而SASL是认证过程,侧重于信任建立过程,这个过程可以调用PAM来建立信任关系。

1.1安装:

[root@ldap-server ~]# yum -y install sasl*  #安装sasl

[root@ldap-server ~]# rpm -qa |grep sasl   #查看安装的软件
saslwrapper-0.14-1.el6.x86_64
cyrus-sasl-lib-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-2.1.23-13.el6_3.1.x86_64
cyrus-sasl-devel-2.1.23-13.el6_3.1.x86_64
saslwrapper-devel-0.14-1.el6.x86_64
cyrus-sasl-plain-2.1.23-13.el6_3.1.x86_64

[root@ldap-server ~]# saslauthd -v  #查看sasl支持的东西
saslauthd 2.1.23
authentication mechanisms: getpwent kerberos5 pam rimap shadow ldap

[root@ldap-server ~]# grep -i mech /etc/sysconfig/saslauthd  #过滤需要修改 的内容
# Mechanism to use when checking passwords.  Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=pam  
# Options sent to the saslauthd. If the MECH is other than "pam" uncomment the next line.

[root@ldap-server ~]# sed -i "s#MECH=pam#MECH=shadow#g"  /etc/sysconfig/saslauthd   #修改需要的内容

[root@ldap-server ~]# grep -i mech /etc/sysconfig/saslauthd   #查看修改后的 结果
# Mechanism to use when checking passwords.  Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=shadow
# Options sent to the saslauthd. If the MECH is other than "pam" uncomment the next line.

[root@ldap-server ~]# /etc/init.d/saslauthd start   #启动sasl
Starting saslauthd:                      [  OK  ]
[root@ldap-server ~]# ps -ef|grep sasl #查看启动后的进程 root 20549 1 0 09:35 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadow root 20551 20549 0 09:35 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadow root 20552 20549 0 09:35 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadow root 20553 20549 0 09:35 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadow root 20554 20549 0 09:35 ? 00:00:00 /usr/sbin/saslauthd -m /var/run/saslauthd -a shadow

 

1.2、测试认证系统用户可以不用操作:

[root@ldap-server ~]# useradd xyyp  #创建系统用户

[root@ldap-server ~]# passwd xyyp   #设置密码

[root@ldap-server ~]# testsaslauthd -uxyyp -p123123   #认证用户
0: NO "authentication failed"   #这里明明创建了系统用户并且/etc/sysconfig/saslauthd里面的pam也改成了shadow,但还是认证失败,这里需要使用命令:setsebool -P allow_saslauthd_read_shadow 1

[root@ldap-server ~]# testsaslauthd -uxyyp -p123123  #再次认证用户
0: OK "Success."

1.3、切换成ldap认证:

[root@ldap-server ~]# sed -i "s#MECH=shadow#MECH=ldap#g" /etc/sysconfig/saslauthd    #把shadow改为ldap

[root@ldap-server ~]# /etc/init.d/saslauthd restart   #重启服务
Stopping saslauthd:                         [  OK  ]
Starting saslauthd:                         [  OK  ]

[root@ldap-server ~]# grep -i mech /etc/sysconfig/saslauthd   #查看结果
# Mechanism to use when checking passwords.  Run "saslauthd -v" to get a list
# of which mechanism your installation was compiled with the ablity to use.
MECH=ldap
# Options sent to the saslauthd. If the MECH is other than "pam" uncomment the next line.

[root@ldap-server ~]# vim /etc/saslauthd.conf   #编辑配置文件添加下面内容  
ldap_sercers: ldap://xyanp.org/
#ldap_uri: ldap://ldap.xyp.xyanp.org/
#ldap_version: 3
#ldap_start_tls: 0
ldap_bind_dn: cn=admin,dc=xyanp,dc=org
ldap_bind_pw: xyp
ldap_search_base: ou=People,dc=xyanp,dc=org
ldap_filter: uid=%U
#ldap_filter: mail=%U@xyanp.org
ldap_password_attr: userPassword
#ldap_sasl: 0                                                                                                                                                             
"/etc/saslauthd.conf" 12L, 327C written                                                                                                                   

[root@ldap-server ~]# /etc/init.d/saslauthd restart   #重启服务
Stopping saslauthd:                         [  OK  ]
Starting saslauthd:                         [  OK  ]
[root@ldap-server ~]# testsaslauthd -uxyp -p123456   #测试认证ldap的用户
0: OK "Success."

搭建svn服务器,并保证能正常运行(不在详细赘述)。

ldap的用户对svn进行测试:

[root@ldap-server svndata]# svn up svn://10.10.10.90/asdoc ./ --username=xyp --password=123456   #将svn账户换成ldap里的用户和密码
svn: warning: cannot set LC_CTYPE locale
svn: warning: environment variable LANG is EN
svn: warning: please check that your locale name is correct
Skipped 'svn://10.10.10.90/asdoc'
Authentication realm: <svn://10.10.10.90:3690> 5a20e44e-42c6-42cb-841a-590b02c4e94d
Username:    #会提示输入用户名和密码,证明ldap的用户是不好使的

[root@ldap-server svndata]# vim /etc/sasl2/svn.conf   #编辑一个配置文件,添加下面内容
pwcheck_method: saslauthd
mech_list: PLAIN LOGIN

[root@ldap-server asdoc]# cd /app/svndata/asdoc/conf/  #切换到svn的配置目录

[root@ldap-server conf]# sed -i "s/# use-sasl = true/use-sasl = true/g" svnserve.conf    #修改一个参数

[root@ldap-server conf]# grep use-sasl svnserve.conf   #查看修改结果
use-sasl = true   

[root@ldap-server conf]# pkill svn  #杀掉svn

[root@ldap-server conf]# ps -ef|grep svn   #查看
root      20847   8217  0 11:03 pts/0    00:00:00 grep svn

[root@ldap-server conf]# svnserve -d -r /app/svndata/   #重新启动svn

[root@ldap-server conf]# ps -ef|grep svn   #查看结果
root      20849   1  0 11:03 ?   00:00:00 svnserve -d -r /app/svndata/
root      20851   8217  0 11:03 pts/0    00:00:00 grep svn

[root@ldap-server conf]# svn co svn://10.10.10.90/asdoc /svndata --username=xyp --password=123456    #使用ldap的用户名密码做同步
-----------------------------------------------------------------------
ATTENTION!  Your password for authentication realm:
<svn://10.10.10.90:3690> 5a20e44e-42c6-42cb-841a-590b02c4e94d
can only be stored to disk unencrypted! You are advised to configure your system so that Subversion can store passwords encrypted, if possible. See the documentation for details. You can avoid future appearances of this warning by setting the value of the 'store-plaintext-passwords' option to either 'yes' or 'no' in '/root/.subversion/servers'. ----------------------------------------------------------------------- Store password unencrypted (yes/no)? yes #提示让保存密码,表示成功

1.4windows客户端测试:

新建一个文件夹,右键进行checkout,弹出下面对话框:

 

=================================================================================到此ldap svn完成

1.5、备注:

虽然ldap认证成功了,但是svn的用户管理还是要在authz这个文件里面进行管理的,比如权限,如果再ldap上创建了一个用户,则需要在authz文件里面进行授权rw权限,如果多个用户的话,则可以建个组,直接给组授权。

转载于:https://www.cnblogs.com/xyp-blog123/p/7692682.html

相关文章:

  • codevs 2620 战壕
  • vue-cli脚手架安装
  • keil 赋值之后再声明变量提示错误error: #268: declaration may not appear after executable statement in block...
  • 正质因数分解
  • 110. Balanced Binary Tree
  • 进程与fork()、wait()、exec函数组
  • Centos_linux系统的区别及实际查看
  • 给Extjs的window弹窗的关闭事件添加验证
  • mysql导入存储过程
  • 系统键盘按钮keyCode大全
  • while(*i++=*t++)都做了些什么。
  • 用call和ret实现子程序
  • 求二叉树高度
  • spring整合javaweb(第二版)
  • 转:依赖注入那些事儿
  • Google 是如何开发 Web 框架的
  • 《深入 React 技术栈》
  • 【干货分享】SpringCloud微服务架构分布式组件如何共享session对象
  • Android组件 - 收藏集 - 掘金
  • css属性的继承、初识值、计算值、当前值、应用值
  • echarts花样作死的坑
  • ES学习笔记(10)--ES6中的函数和数组补漏
  • gf框架之分页模块(五) - 自定义分页
  • Js基础——数据类型之Null和Undefined
  • opencv python Meanshift 和 Camshift
  • Perseus-BERT——业内性能极致优化的BERT训练方案
  • React-redux的原理以及使用
  • Sass Day-01
  • Spark学习笔记之相关记录
  • 第2章 网络文档
  • 精彩代码 vue.js
  • 微信开源mars源码分析1—上层samples分析
  • 新版博客前端前瞻
  • 译有关态射的一切
  • 白色的风信子
  • 【云吞铺子】性能抖动剖析(二)
  • 阿里云重庆大学大数据训练营落地分享
  • ​Java并发新构件之Exchanger
  • ​LeetCode解法汇总2182. 构造限制重复的字符串
  • ​Python 3 新特性:类型注解
  • ​软考-高级-系统架构设计师教程(清华第2版)【第9章 软件可靠性基础知识(P320~344)-思维导图】​
  • #etcd#安装时出错
  • (10)STL算法之搜索(二) 二分查找
  • (C++17) optional的使用
  • (C++17) std算法之执行策略 execution
  • (亲测)设​置​m​y​e​c​l​i​p​s​e​打​开​默​认​工​作​空​间...
  • (四) 虚拟摄像头vivi体验
  • (四)图像的%2线性拉伸
  • (原创)Stanford Machine Learning (by Andrew NG) --- (week 9) Anomaly DetectionRecommender Systems...
  • (原創) 如何使用ISO C++讀寫BMP圖檔? (C/C++) (Image Processing)
  • (最简单,详细,直接上手)uniapp/vue中英文多语言切换
  • .java 9 找不到符号_java找不到符号
  • .NET/C# 阻止屏幕关闭,阻止系统进入睡眠状态
  • .netcore 6.0/7.0项目迁移至.netcore 8.0 注意事项
  • .netcore如何运行环境安装到Linux服务器