修改openLDAP管理员密码(docker-compose非容器方式/容器化方式/docker-compose)

1. 非容器化方式

非容器化ldap更改管理员密码

1.1 查看管理员信息

  • 命令
ldapsearch -H ldapi:// -LLL -Q -Y EXTERNAL -b "cn=config" "(olcRootDN=*)" dn olcRootDN olcRootPW
  • 输出
dn: olcDatabase={0}config,cn=config
olcRootDN: cn=admin,cn=config
olcRootPW: {SSHA}QkwgTsAVaNGf2gBrbA/3t4ZsMrhQoXjI
dn: olcDatabase={1}mdb,cn=config
olcRootDN: cn=admin,dc=example,dc=org
olcRootPW: {SSHA}j8m5H73mNVPYwJQv8Iz1UvU1uVddKDIJ

如上可见,我们要修改的是第二段的cn=admin,dc=example,dc=org用户密码

1.2 获取密码的加密字串

root@9bf3f3854cf8:/# slappasswd -s flzxxxxxxxt
{SSHA}YQUNQLtt3xxxxxxxxxxxxxxxx

1.3 生成密码修改文件

cat > /root/newpasswd.ldif <<"EOF"
dn: olcDatabase={1}mdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: {SSHA}YQUNQLtt3xxxxxxxxxxxxxxxx
EOF

该文件用于修改管理员密码密码

  • dn: olcDatabase={1}mdb,cn=config,是1.1 中查出的数据
  • olcRootPW: 是1.2中获取的加密字串

1.4 修改密码

ldapmodify -H ldapi:// -Y EXTERNAL -f /root/newpasswd.ldif

执行后新密码立即生效

1.5 问题

该方法旧密码在过期前仍然会生效。

2. 容器化方式

容器化方式启动的ldap,启动脚本会从环境变量中读取字串设置为密码,其变量如下:

  • LDAP_ADMIN_PASSWORD:1.1 中查到的cn=admin,dc=example,dc=org用户的密码变量。
  • LDAP_CONFIG_PASSWORD:1.1 中查到的cn=admin,cn=config用户的密码变量
  • 我们直接在docker-compose.yml中添加如下字段即可
openldap:
environment:
#- LDAP_CONFIG_PASSWORD=liube@161
- LDAP_ADMIN_PASSWORD=liubei@161

在这里插入图片描述

posted on   运维开发玄德公  阅读(142)  评论(0编辑  收藏  举报  

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示