背景

实验室搭建的很多系统都提供自己的用户管理功能,比如openstack、zabbix、openvas、jumpserver,但使用这些系统的又是同一批同学,导致账户密码重复的存在于每个系统。同时又有一些系统依赖其他用户管理系统而运行,如radius。
LDAP是一种目录数据库,每条目(entry)以树状组织在数据库中,适合用于描述现实世界众多树状的组织人员架构,一般使用开源的openldap。
LAM是图形化登录管理使用LDAP的CMS系统,有免费版和pro版。
RADIUS是一种用于进行认证授权审计(3A)的协议,向北提供各类认证框架协议的服务,向南从数据库查询用户名、密码或哈希等,经过对比后,给北向返回认证成功或失败的结果,而北向的RADIUS客户端是其他服务的服务端,拿到认证结果后,根据结果对用户的请求做出不同的反应,如无线AP的是否允许设备连入。

目标

快速拉起一套LDAP+LAM+RADIUS,能够:

  1. LDAP提供manager用户用于管理员对人员增删改查
  2. LDAP设置ACL策略使除manager外的用户仅能查看自己的信息、修改自己的密码
  3. LDAP提供readonly用户用于一些不支持radius认证的系统,如jumpserver仅从ldap导出用户数据
  4. LAM提供WEB界面供普通用户与管理员图形化管理
  5. RADIUS支持PEAP-MSCHAPV2模式的企业无线认证(LDAP中需要存储用户密码的微软NT哈希)

    LDAP

    LDAP的部署教程多之又多,大部分停留在编写slapd.conf配置文件从而初始化生成树形数据结构的方式,然而官方文档已经写明2.3版本以后使用ldif进行初始化,配置文件以兼容的方式保留并后续会被淘汰。

    The older style slapd.conf(5) file is still supported, but its use is deprecated and support for it will be withdrawn in a future OpenLDAP release.

接下来的介绍基于对https://www.openldap.org/doc/admin26/的阅读,admin26即2.6版本的使用文档。

名词解释

DN:globally-unique Distinguished Name,一条entry的唯一标识,是从树根到树枝的路径,如uid=babs,ou=People,dc=example,dc=com,最左为树枝,最右为树根。
DC:Domain Component,域名的一部分,如dc=example,dc=com
ou:Organizational Unit,组织部门,如开发组、测试组
cn:common name,节点的人读名称
schema:ldap树中的任意节点均可存储数据,类比mysql的schema指定了数据表的模式,ldap中schema可以提供objectclass对象,它规定了节点应该具有的xxx属性。在树结构中为节点指定objectclass,即可使节点遵守对应的数据模式。

目录组织

LDAP能存储任意形状的树,那究竟使用它存储哪种形状的树呢?如何设计LDAP存储的数据结构?:
传统的组织方式以国家公司架构进行设计,如
LDAP LAM RADIUS - 图1
现在比较流行以公司域名进行组织,即
LDAP LAM RADIUS - 图2

注意LDAP的树结构数据 与 节点内容数据 分开存储,树的结构与每个节点(树结构数据)需遵循的objectclass存储在配置文件目录中,常见于/etc/openldap/slapd.d/,节点的所有属性数据(节点内容数据)由存储backend配置决定,如mdb后端常存储在/var/lib/ldap。

开始搭建

安装

安装方式根据自身需要进行选择,https://www.openldap.org/doc/admin26/install.html
本文选择基于docker的方式,构建ldap镜像,Dockerfile内容为

  1. FROM alpine:3.15
  2. RUN apk add --no-cache openldap openldap-backend-all openldap-overlay-all openldap-clients
  3. ADD schema/* /etc/openldap/schema/
  4. ENV COMMAND="slapd -d 1 -F /data"

alpine系统的3.15版本安装的是openldap的2.6版本,一劳永逸的安装了所有的ldap存储后端backend、以及overlay插件,还安装了ldap的客户端以供测试。
最后容器命令设定为从/data目录读取树状结构数据,debug级别调整为1,此时会驻留在前台避免容器进程退出。
拉起容器只需将持久化目录以及后一小节的ldif文件挂载进去即可,如docker run -d --name ldap -p 389:389 -p 636:636 -v xxx:/data -v yyy:/ldap ldap:latest

配置

配置文件根据https://www.openldap.org/doc/admin26/slapdconf2.html文档的示例配置修改而来,文件命名为init.ldif,修改内容如下:

  1. 14、15行的pid存储路径,修改为/var/run目录
  2. 34行加载存储后端模块名称,由.la后缀修改为.so后缀,因为alpine中安装ldap不存在.la文件
  3. 43-48行加载所需的schema,其中openldap不提供samba.ldif,需要自己去寻找(我从其他ldap镜像复制过来)
  4. 88行以后是修改集中的区域:
    1. olcSuffix:树状结构的根,即dc=sechnic,dc=com
    2. olcRootDN:mdb数据库的root用户,不受ACL限制,拥有所有权限
    3. olcDbDirectory:节点内容数据存储目录,指定与树结构数据相同的目录,从而只需挂载一个目录进入容器即可持久化
    4. 105-106行指定ACL规则,语法大致为to 一些实体 by 一些entry 可读可写 by 另一些entry可读 by ...,文档位于https://www.openldap.org/doc/admin26/access-control.html。目标中的123主要功能均由ACL实现。
  5. 注意:一个LDAP服务端能同时管理多个backend,每个backend存储一个domain或者说olcSuffix ```

    https://www.openldap.org/doc/admin26/slapdconf2.html

    https://www.openldap.org/doc/admin26/quickstart.html

    #

    See slapd-config(5) for details on configuration options.

    This file should NOT be world readable.

    # dn: cn=config objectClass: olcGlobal cn: config # #

    Define global ACLs to disable default read access.

    # olcArgsFile: /var/run/slapd.args olcPidFile: /var/run/slapd.pid #

    Do not enable referrals until AFTER you have a working directory

    service AND an understanding of referrals.

    olcReferral: ldap://root.openldap.org

    #

    Sample security restrictions

    Require integrity protection (prevent hijacking)

    Require 112-bit (3DES or better) encryption for updates

    Require 64-bit encryption for simple bind

    olcSecurity: ssf=1 update_ssf=112 simple_bind=64

#

Load dynamic backend modules:

# dn: cn=module,cn=config objectClass: olcModuleList cn: module olcModulepath: /usr/lib/openldap olcModuleload: back_mdb.so

olcModuleload: back_ldap.la

olcModuleload: back_passwd.la

dn: cn=schema,cn=config objectClass: olcSchemaConfig cn: schema

include: file:///etc/openldap/schema/core.ldif include: file:///etc/openldap/schema/cosine.ldif include: file:///etc/openldap/schema/inetorgperson.ldif include: file:///etc/openldap/schema/openldap.ldif include: file:///etc/openldap/schema/nis.ldif include: file:///etc/openldap/schema/samba.ldif

Frontend settings

# dn: olcDatabase=frontend,cn=config objectClass: olcDatabaseConfig objectClass: olcFrontendConfig olcDatabase: frontend #

Sample global access control policy:

Root DSE: allow anyone to read it

Subschema (sub)entry DSE: allow anyone to read it

Other DSEs:

Allow self write access

Allow authenticated users read access

Allow anonymous users to authenticate

#

olcAccess: to dn.base=”” by * read

olcAccess: to dn.base=”cn=Subschema” by * read

olcAccess: to *

by self write

by users read

by anonymous auth

#

if no access controls are present, the default policy

allows anyone and everyone to read anything but restricts

updates to rootdn. (e.g., “access to by read”)

#

rootdn can always read and write EVERYTHING!

#

LMDB database definitions

#

# dn: olcDatabase=monitor,cn=config objectClass: olcDatabaseConfig olcDatabase: monitor olcRootDN: cn=config olcMonitoring: FALSE

dn: olcDatabase=mdb,cn=config objectClass: olcDatabaseConfig objectClass: olcMdbConfig olcDatabase: mdb olcDbMaxSize: 1073741824 olcSuffix: dc=sechnic,dc=com olcRootDN: cn=admin,ou=users,dc=sechnic,dc=com

Cleartext passwords, especially for the rootdn, should

be avoided. See slappasswd(8) and slapd-config(5) for details.

Use of strong authentication encouraged.

olcRootPW: admin123

The database directory MUST exist prior to running slapd AND

should only be accessible by the slapd and slap tools.

Mode 700 recommended.

olcDbDirectory: /data/

Indices to maintain

olcDbIndex: objectClass eq olcAccess: to attrs=userPassword,sambaHomeDrive,sambaAcctFlags,displayName,shadowLastChange,sambaNTPassword,sambaPwdLastSet by self write by dn.base=”cn=manager,ou=users,dc=sechnic,dc=com” write by anonymous auth by none olcAccess: to by self read by dn.base=”cn=manager,ou=users,dc=sechnic,dc=com” write by dn=”cn=readonly,ou=users,dc=sechnic,dc=com” read by * search

  1. <a name="dSiuK"></a>
  2. ### 运行
  3. 首先根据上一小节中编写的配置文件离线生成树结构数据,注意替换容器命令为`sleep 100d`避免容器找不到配置文件而挂掉,进入容器后执行:<br />`slapadd -n 0 -F /data -l /ldap/init.ldif`<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022119611-a512e979-7530-4767-a777-b2f9fa4b9337.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=82&id=ub24e61d0&margin=%5Bobject%20Object%5D&name=image.png&originHeight=163&originWidth=736&originalType=binary&ratio=1&rotation=0&showTitle=false&size=17192&status=done&style=none&taskId=u6322551d-b25f-49c9-acee-861e8765c7a&title=&width=368)<br />若有报错,调整init.ldif后需要清空/data/目录后重新执行slapadd。<br />最后取消对命令的修改,重新拉起容器,进入容器进行测试校验:<br />`ldapsearch -x -b '' -s base '(objectclass=*)' namingContexts`<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022182778-4e7a6315-3741-4051-b934-6361e0599935.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=260&id=ue619324e&margin=%5Bobject%20Object%5D&name=image.png&originHeight=519&originWidth=998&originalType=binary&ratio=1&rotation=0&showTitle=false&size=38135&status=done&style=none&taskId=ua4175ea5-e273-4cc5-bc98-cfe09b61b44&title=&width=499)<br />至此完成树结构的创建,后续users、groups等树枝,以及节点内容的创建,均通过LAM在图形化界面中完成。
  4. <a name="fwssl"></a>
  5. # LAM
  6. <a name="HcBZg"></a>
  7. ## 开始搭建
  8. <a name="lfwjr"></a>
  9. ### 安装
  10. 同样使用容器化部署,直接使用官网提供的镜像:ldapaccountmanager/lam:7.7
  11. <a name="Jvkq0"></a>
  12. ### 运行
  13. `docker run -d --name lam -p 82:80 ldapaccountmanager/lam:7.7`
  14. <a name="tGT5b"></a>
  15. ### 配置
  16. 打开lam的web端:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022632207-bb4176d1-ea9b-4c13-9360-64c49fa1dd8f.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=447&id=u0e704548&margin=%5Bobject%20Object%5D&name=image.png&originHeight=894&originWidth=1799&originalType=binary&ratio=1&rotation=0&showTitle=false&size=73688&status=done&style=none&taskId=u8276e4fa-f9c9-4134-af0a-ed8e061b540&title=&width=899.5)<br />LAM的一个profile对应一个LDAP的backend数据库,都对应着一个域,即sechnic.com,首先进行profile配置,点击右上角LAM configuration<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022716246-f45f1f32-818b-450f-84c5-eec5c311f3b7.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=420&id=ufda96be0&margin=%5Bobject%20Object%5D&name=image.png&originHeight=839&originWidth=1796&originalType=binary&ratio=1&rotation=0&showTitle=false&size=54137&status=done&style=none&taskId=uc9978945-1286-4b7d-9269-ff404e3a75c&title=&width=898)<br />点击Edit server profiles<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022742548-c40e4119-666d-4fbe-ad1c-e199fcfc3d5c.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=405&id=u6af08207&margin=%5Bobject%20Object%5D&name=image.png&originHeight=809&originWidth=1813&originalType=binary&ratio=1&rotation=0&showTitle=false&size=46999&status=done&style=none&taskId=u8a2213e5-c93f-4eeb-9357-1db5db7f986&title=&width=906.5)<br />这个名为lam的profile的默认密码为lam,登录进去<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022764957-07a4acfc-8a3a-4c71-af9b-917f558c8eec.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=501&id=uae518820&margin=%5Bobject%20Object%5D&name=image.png&originHeight=1001&originWidth=1810&originalType=binary&ratio=1&rotation=0&showTitle=false&size=122441&status=done&style=none&taskId=udb8f1c69-939e-4e17-998d-0ffbafdc5d9&title=&width=905)<br />首先进行通用配置
  17. 1. server address填ldap的容器IP或域名
  18. ![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022853305-94fc9dc3-0b03-448b-af68-b92a827b7c0c.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=479&id=u533baf13&margin=%5Bobject%20Object%5D&name=image.png&originHeight=957&originWidth=1697&originalType=binary&ratio=1&rotation=0&showTitle=false&size=83575&status=done&style=none&taskId=ud03a7d62-9abe-4df2-9f73-b39c87e4414&title=&width=848.5)
  19. 2. Tree suffix填写域前缀
  20. 2. Login method指定了登录LAM系统的用户从哪里来,此时我们还没创建任何用户,因此静态的指定如果登录,就使用数据库root用户登录
  21. ![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639022971688-bf044d9c-4f9e-4d2d-8d1c-36d33fdd3ffa.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=489&id=u39b6efc9&margin=%5Bobject%20Object%5D&name=image.png&originHeight=978&originWidth=1783&originalType=binary&ratio=1&rotation=0&showTitle=false&size=147137&status=done&style=none&taskId=ua777691c-2bb2-4fdc-8e4c-8529a726a81&title=&width=891.5)<br />接下来进行account types配置,这里配置的是在域前缀dc=xxx,dc=com的树干上,需要有哪些树枝:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023054739-6f2d7a86-4dd7-412e-a1f0-ecdbd06c9717.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=495&id=u06ba5dc9&margin=%5Bobject%20Object%5D&name=image.png&originHeight=990&originWidth=1472&originalType=binary&ratio=1&rotation=0&showTitle=false&size=140166&status=done&style=none&taskId=u5134d5d1-e0dc-4ebe-bf62-586edd85b41&title=&width=736)<br />默认只有users和groups,点击samba domains后面的绿色加号添加smb域的树枝,并为每个树枝填写他们各自的前缀,如ou=users,dc=sechnci,dc=com。接下来进行modules配置:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023165672-f61117f0-8ffb-4aea-a404-bf6724640f77.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=492&id=uec3cb868&margin=%5Bobject%20Object%5D&name=image.png&originHeight=984&originWidth=1762&originalType=binary&ratio=1&rotation=0&showTitle=false&size=156002&status=done&style=none&taskId=ub81df57a-dc24-4bd2-87af-00476ec0016&title=&width=881)<br />modules这里配置了,每个树枝上的小树枝需要遵守的模式(objectclass(由schema文件定义)),如users需要遵守PosixAcount这个模式,创建一个新的user时,就必须根据这个模式指定类型的属性。<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023303122-9b716d9f-775e-4edb-be09-9e8fd672faca.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=296&id=u2ff05091&margin=%5Bobject%20Object%5D&name=image.png&originHeight=592&originWidth=1276&originalType=binary&ratio=1&rotation=0&showTitle=false&size=93852&status=done&style=none&taskId=u3b4cd1da-f80f-4162-861d-f19f0bda4a2&title=&width=638)<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023308603-4dc36e91-bcaa-4eff-9c5b-7d452876fb59.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=426&id=u3d8c1b68&margin=%5Bobject%20Object%5D&name=image.png&originHeight=852&originWidth=1402&originalType=binary&ratio=1&rotation=0&showTitle=false&size=98005&status=done&style=none&taskId=ue39839fb-a552-49ef-8e9b-0dc6670910d&title=&width=701)<br />我们这里将Samba3从右侧加到users的左侧,即为用户设置密码时,除了明文的密码,还计算NT哈希存储到属性中(sambaSAMAcount模式规定的),以供后续的radius认证时使用。<br />此外还将两个module都添加到Samba domains。<br />最后Module Setting暂时无需设置,点击最下面的save保存,跳转回登录界面:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023482524-e9d3616d-567f-4085-8b03-c98a01670171.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=407&id=ua1570004&margin=%5Bobject%20Object%5D&name=image.png&originHeight=813&originWidth=1806&originalType=binary&ratio=1&rotation=0&showTitle=false&size=76939&status=done&style=none&taskId=u56797709-d8d4-4f62-a354-9cefc5dcbf1&title=&width=903)<br />以init.ldif中的root密码登录<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023508296-b711266c-599b-4bfc-b644-8f960fafd471.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=276&id=ud3c13034&margin=%5Bobject%20Object%5D&name=image.png&originHeight=552&originWidth=1799&originalType=binary&ratio=1&rotation=0&showTitle=false&size=75102&status=done&style=none&taskId=u07fc7f74-8147-418b-acc8-ab42bad2a56&title=&width=899.5)<br />LAM检测到三个树枝users、groups、domains还没有创建,询问是否创建,点击create。<br />在创建一个用户前,需要先创建group和samba domain:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023568911-bc5db5e1-4bbc-4519-b7a6-608c3166bd94.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=270&id=u61852ea9&margin=%5Bobject%20Object%5D&name=image.png&originHeight=540&originWidth=1808&originalType=binary&ratio=1&rotation=0&showTitle=false&size=60616&status=done&style=none&taskId=u6dab0bb9-f399-4911-909b-c145575c185&title=&width=904)<br />点击new domain<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023596154-b8305b6f-dda2-4f56-a012-e895ad8bb4f1.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=372&id=uadd77da0&margin=%5Bobject%20Object%5D&name=image.png&originHeight=744&originWidth=1775&originalType=binary&ratio=1&rotation=0&showTitle=false&size=136864&status=done&style=none&taskId=u1236e9c0-10d7-45ae-b04c-10e3de43093&title=&width=887.5)<br />名称随意,SID填写S-1-5-21-1050648551-1543052747-425021240,点击Save保存<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023629773-e2a71e85-015c-4650-9a61-8580110b293b.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=326&id=uc4fc5682&margin=%5Bobject%20Object%5D&name=image.png&originHeight=652&originWidth=1803&originalType=binary&ratio=1&rotation=0&showTitle=false&size=87725&status=done&style=none&taskId=u5e4b4ff5-4b37-4dd9-bdf1-8c87f2f8b37&title=&width=901.5)<br />同理创建新的group,名称任意,点击save保存<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023654046-0d05fcd2-c4f6-41b0-8cb7-e902f1bad430.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=457&id=uea8426cb&margin=%5Bobject%20Object%5D&name=image.png&originHeight=914&originWidth=1787&originalType=binary&ratio=1&rotation=0&showTitle=false&size=137096&status=done&style=none&taskId=u97be6e5c-8579-4616-8ca6-0c9013fe15a&title=&width=893.5)<br />开始创建用户,首先是manager,根据ACL规则他拥有权利管理其他用户,点击unix,点击后无需配置<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023709593-d1e6a6fe-2efd-40b0-9f48-8dd5ced829c3.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=361&id=uc264aed9&margin=%5Bobject%20Object%5D&name=image.png&originHeight=722&originWidth=1786&originalType=binary&ratio=1&rotation=0&showTitle=false&size=98459&status=done&style=none&taskId=ud07831a8-9fbf-466a-9f7d-8ef34a7af42&title=&width=893)<br />点击samba3,点击Add Extension后无需配置<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023742119-3d713262-3ce5-4e27-8f79-08256d3140df.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=461&id=u21decb22&margin=%5Bobject%20Object%5D&name=image.png&originHeight=921&originWidth=1804&originalType=binary&ratio=1&rotation=0&showTitle=false&size=139965&status=done&style=none&taskId=uf1073d7f-91ec-49bc-86b2-c3b90d88fd6&title=&width=902)<br />点击set password设置密码,设置后保存<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023798826-f836017e-0fe7-4247-928f-bf0c12fd6165.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=205&id=u5aa309ff&margin=%5Bobject%20Object%5D&name=image.png&originHeight=410&originWidth=1722&originalType=binary&ratio=1&rotation=0&showTitle=false&size=47875&status=done&style=none&taskId=uafdb8a6d-5e21-4656-934f-e47d6f224f3&title=&width=861)<br />同理创建readonly用户。接下来我们设置LAM以ou=users中的用户登录,而不是永远以root用户登录:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023850519-5ef57063-746b-4427-a081-de795a775b12.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=490&id=uaf6f27bf&margin=%5Bobject%20Object%5D&name=image.png&originHeight=979&originWidth=1778&originalType=binary&ratio=1&rotation=0&showTitle=false&size=115855&status=done&style=none&taskId=u6c5a4c69-fd8d-4749-95fb-6bb645afc07&title=&width=889)<br />回到lam profile的配置页面<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639023898619-b7b7aec1-9c69-41ea-bf9e-da3bc10d7958.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=186&id=u0348c5c7&margin=%5Bobject%20Object%5D&name=image.png&originHeight=371&originWidth=1414&originalType=binary&ratio=1&rotation=0&showTitle=false&size=44386&status=done&style=none&taskId=uffb08362-ddf8-4560-8947-a84f83aebb4&title=&width=707)<br />login method改为search,这样LAM在登录界面会在ou=users中搜索(cn=username)用户提供的用户名,而在搜索时LAM需要先以拥有搜索权限的用户登录至LDAP,我们为他配置readonly用户,根据ACL规则有读取和搜索权限。<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639024020080-e3cc1329-bc17-42dd-9e04-efb9bb277057.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=409&id=uc49f0a42&margin=%5Bobject%20Object%5D&name=image.png&originHeight=817&originWidth=1687&originalType=binary&ratio=1&rotation=0&showTitle=false&size=56655&status=done&style=none&taskId=ua98ef4c7-b8ad-427b-9bfe-fc460a3302b&title=&width=843.5)<br />保存后,以刚刚添加的manager登录<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639024040810-e3d2b5c3-cc2e-4070-98ce-673799238813.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=309&id=ue991d2b0&margin=%5Bobject%20Object%5D&name=image.png&originHeight=617&originWidth=1777&originalType=binary&ratio=1&rotation=0&showTitle=false&size=83412&status=done&style=none&taskId=u4c9f09c6-cee1-480c-b9ff-46f8a296bc9&title=&width=888.5)<br />能看到所有的用户列表,添加新的普通用户,添加方式相同:<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639024111512-345bd395-4b3f-4cef-b258-ca841c51618b.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=298&id=uff984844&margin=%5Bobject%20Object%5D&name=image.png&originHeight=595&originWidth=1793&originalType=binary&ratio=1&rotation=0&showTitle=false&size=90325&status=done&style=none&taskId=u8f3e3921-540a-467e-9a44-b9e2dac471d&title=&width=896.5)<br />logout后,以普通用户登录,只能看到本用户的信息,同时能够自行重置密码。<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/22116370/1639024122970-bf272122-16f7-45e9-b31c-e4f7176f99e5.png#clientId=u4379e380-3deb-4&crop=0&crop=0&crop=1&crop=1&from=paste&height=253&id=u54f24a3d&margin=%5Bobject%20Object%5D&name=image.png&originHeight=506&originWidth=1749&originalType=binary&ratio=1&rotation=0&showTitle=false&size=69263&status=done&style=none&taskId=u029c9840-fdc3-406f-904c-d12c49c1f48&title=&width=874.5)<br />至此,LAM的配置完成,可以使用manager用户进行普通用户的管理,普通用户也能登录到LAM进行密码的修改。
  22. <a name="zcmsL"></a>
  23. # RADIUS
  24. <a name="bvoM5"></a>
  25. ### 配置
  26. 搭建运行部分省略,同样可以使用公开的raidus镜像拉起容器,<br />配置部分注意需要修改ldap、eap的module配置,以及运行用户的配置

diff —git a/radius/clients.conf b/radius/clients.conf index 9dbc3e9..4cefcfc 100644 —- a/radius/clients.conf +++ b/radius/clients.conf @@ -266,3 +266,10 @@ client localhost_ipv6 {

secret = testing123

}

}

+ +client any {

  • ipaddr = 0.0.0.0/0
  • secret = 5699923
  • require_message_authenticator = no + +} diff —git a/radius/mods-available/eap b/radius/mods-available/eap index 249d37f..6148b52 100644 —- a/radius/mods-available/eap +++ b/radius/mods-available/eap @@ -24,7 +24,7 @@ eap {

    then that EAP type takes precedence over the

    default type configured here.

    #
  • default_eap_type = md5
  • default_eap_type = peap

    A list is maintained to correlate EAP-Response

    packets with EAP-Request packets. After a

    diff —git a/radius/mods-available/ldap b/radius/mods-available/ldap index 7ab829f..9ec5d36 100644 —- a/radius/mods-available/ldap +++ b/radius/mods-available/ldap @@ -16,7 +16,7 @@ ldap {

    - ldaps:// (LDAP over SSL)

    - ldapi:// (LDAP over Unix socket)

    - ldapc:// (Connectionless LDAP)

  • server = ‘localhost’
  • server = ‘ldap’

    server = ‘ldap.rrdns.example.org’

    server = ‘ldap.rrdns.example.org’

@@ -25,12 +25,12 @@ ldap {

  1. # Administrator account for searching and possibly modifying.
  2. # If using SASL + KRB5 these should be commented out.

-# identity = ‘cn=admin,dc=example,dc=org’ -# password = mypass

  • identity = ‘cn=root,dc=sechnic,dc=com’
  • password = toor

    Unless overridden in another section, the dn from which all

    searches will start from.

  • base_dn = ‘dc=example,dc=org’
  • base_dn = ‘dc=sechnic,dc=com’

    #

    You can run the ‘ldapsearch’ command line tool using the

    @@ -127,6 +127,8 @@ ldap {

    attribute ref.

    update {

    1. control:Password-With-Header += 'userPassword'
  • control:NT-Password := ‘sambaNTPassword’
  • reply:Reply-Message := ‘sambaPwdLastSet’

    control:NT-Password := ‘ntPassword’

    reply:Reply-Message := ‘radiusReplyMessage’

    reply:Tunnel-Type := ‘radiusTunnelType’

    @@ -188,7 +190,7 @@ ldap { # user {

    Where to start searching in the tree for users

  • base_dn = “${..base_dn}”
  • base_dn = “ou=users,${..base_dn}”

    Filter for user objects, should be specific enough

    to identify a single user object.

    @@ -554,7 +556,7 @@ ldap {

    The StartTLS operation is supposed to be

    used with normal ldap connections instead of

    using ldaps (port 636) connections

    -# start_tls = yes

  • start_tls = no

    ca_file = ${certdir}/cacert.pem

@@ -574,7 +576,7 @@ ldap {

  1. # The default is libldap's default, which varies based
  2. # on the contents of ldap.conf.

-# require_cert = ‘demand’

  • require_cert = ‘never’ }

    As of version 3.0, the ‘pool’ section has replaced the

    diff —git a/radius/mods-enabled/ldap b/radius/mods-enabled/ldap new file mode 120000 index 0000000..a8ab497 —- /dev/null +++ b/radius/mods-enabled/ldap @@ -0,0 +1 @@ +../mods-available/ldap \ No newline at end of file diff —git a/radius/peap-mschapv2.conf b/radius/peap-mschapv2.conf new file mode 100644 index 0000000..d401738 —- /dev/null +++ b/radius/peap-mschapv2.conf @@ -0,0 +1,10 @@ +network={

  • ssid=”example”
  • key_mgmt=WPA-EAP
  • eap=PEAP
  • identity=”add”
  • anonymous_identity=”anonymous”
  • password=”xxx”
  • phase2=”autheap=MSCHAPV2”
  • ca_cert=”/etc/raddb/certs/ca.der”

    +} diff —git a/radius/radiusd.conf b/radius/radiusd.conf index a840006..ed32861 100644 —- a/radius/radiusd.conf +++ b/radius/radiusd.conf @@ -501,8 +501,8 @@ security {

    member. This can allow for some finer-grained access

    controls.

    #
  • user = freerad
  • group = freerad
  • user = radius
  • group = radius

    Core dumps are a bad thing. This should only be set to

    ‘yes’ if you’re debugging a problem with the server.

    ```