Install-ApacheDS
- ApacheDS安装 [ LDAP和Kerberos ] 配置
- apacheDS ldap 安装,配置,增删查该及备份恢复
- (超详细图文)apacheDS安装与LDAP/kerberos配置
- 快速搭建Kerberos服务端及入门使用
一 .前言
1.1. 安装包
1.2. 名词含义
| 名词 | 全称 | 含义 |
|---|---|---|
| CN | Common Name | 为用户名或服务器名,最长可以到80个字符,可以为中文; |
| OU | Organization Unit | 为组织单元,最多可以有四级,每级最长32个字符,可以为中文; |
| DC | Domain Component | 域组件 |
LDAP 目录类似于文件系统目录。
下列目录:
DC=redmond,DC=wa,DC=microsoft,DC=com
如果我们类比文件系统的话,可被看作如下文件路径:
Com\Microsoft\Wa\Redmond
例如:CN=test,OU=developer,DC=domainname,DC=com
在上面的代码中
cn=test 可能代表一个用户名,
ou=developer 代表一个 active directory 中的组织单位。
这句话的含义可能就是说明 :
test 这个对象处在domainname.com 域的 developer 组织单元中。
二 .安装apacheDS
2.1. 安装ApacheDS
设置安装目录,设置JDK位置
2.2. 安装Apache Directory Studio
注意: Apache Directory Studio 安装有点坑, 要求JDK必须为11以上. 需要修改 ApacheDirectoryStudio.ini
-startup
plugins/org.eclipse.equinox.launcher_1.6.0.v20200915-1508.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.2.0.v20200915-1442
/studio-rcp/resources/icons/linux/studio.xpm
###
#Uncomment_to_configure_the_language
#https://directory.apache.org/studio/faqs.html#how-to-set-the-language-of-studio
#-nl
#en
###
#Uncomment_to_configure_Java_version_to_use
#https://directory.apache.org/studio/faqs.html#how-to-set-the-java-vm-to-use
#-vm
#/usr/lib/jvm/java-11-openjdk/bin/java
-vm
D:/Develop/jdk/jdk-17/bin/java
-vmargs
-Dosgi.requiredJavaVersion=11
###
#Uncomment_to_configure_heap_memory
#https://directory.apache.org/studio/faqs.html#how-to-increase-the-heap-memory
#-Xms1g
#-Xmx2g
2.3. 配置连接
创建连接,设置连接信息,默认端口为: 10389

点击Next,设置用户信息

默认账号
- user:
uid=admin,ou=system - password:
secret
点击Finish保存即可

2.4. 设置分区
右击新建的连接名称ApacheDS,选择 Open Configuration,切换到Partitions页签

点击Add

- ID: light
- Suffix: dc=light,dc=com
Ctrl+S保存, 重启ApacheDS
2.5. 添加组
右键点击新建的 Partition - New - New Entry

点击 Next

选择organizationUnit点击Add

点击 Next

填入RDN信息 ou = Group,点击Next

点击Finish

三 .修改配置
3.1. linux用户schema
刷新 ou=schema

将cn=nis的属性m-disabled配置修改为False,修改之后就可以有posixAccount、posixGroup相关属性。

3.2. 添加测试组
断开连接,重新刷新


添加组,右键点击新建的 ou=Group - New - New Entry

点击Next

搜索po,如果没有值可以刷新一下

选择 posixGroup,点击Add

填入RDN信息 cn = test,点击Next

点击Finish


3.3. 添加用户
创建test.ldif文件
dn: uid=test,ou=Group,dc=light,dc=com
uid: test
cn: test
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
userPassword: {crypt}!!
shadowLastChange: 18663
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1000
gidNumber: 0
homeDirectory: /home/test
选择刚创建的文件导入用户

如果要覆盖之前的,可以勾选 Overwrite existing logfile


3.4. 修改用户密码
双击修改用户密码,将密码改为test



四 .LDAP用户同步
4.1. 安装LDAP client
前置环境处理
- 关闭SELinux
[root@localhost ~]# setenforce 0
setenforce: SELinux is disabled
[root@localhost ~]# sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
[root@localhost ~]# grep SELINUX=disabled /etc/selinux/config
SELINUX=disabled
- 关闭iptables
查看防火墙状态
firewall-cmd --state
停止firewall
systemctl stop firewalld.service
禁止firewall开机启动
systemctl disable firewalld.service
- 在需要同步的物理机上执行安装指令
yum install nss-pam-ldapd openldap-clients openldap -y
4.2. 配置LDAP client
- 添加client服务器到LDAP服务,注意IP
[root@localhost ~]# authconfig --enablemkhomedir --disableldaptls --enableldap --enableldapauth --ldapserver="192.168.101.30:10389" --ldapbasedn="dc=yss,dc=com" --update
getsebool: SELinux is disabled
[root@localhost ~]#
这个指令修改了/etc/nsswitch.conf 以及/etc/openldap/ldap.conf文件
- /etc/nsswitch.conf
[root@localhost ~]# cat /etc/nsswitch.conf |egrep -v "^#|^$"
passwd: files sss ldap
shadow: files sss ldap
group: files sss ldap
hosts: files dns myhostname
bootparams: nisplus [NOTFOUND=return] files
ethers: files
netmasks: files
networks: files
protocols: files
rpc: files
services: files sss
netgroup: files sss ldap
publickey: nisplus
automount: files ldap
aliases: files nisplus
[root@localhost ~]#
- /etc/pam.d/system-auth
[root@localhost ~]# cat /etc/pam.d/system-auth
#%PAM-1.0
# This file is auto-generated.
# User changes will be destroyed the next time authconfig is run.
auth required pam_env.so
auth required pam_faildelay.so delay=2000000
auth sufficient pam_unix.so nullok try_first_pass
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth sufficient pam_ldap.so use_first_pass
auth required pam_deny.so
account required pam_unix.so broken_shadow
account sufficient pam_localuser.so
account sufficient pam_succeed_if.so uid < 1000 quiet
account [default=bad success=ok user_unknown=ignore] pam_ldap.so
account required pam_permit.so
password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type=
password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok
password sufficient pam_ldap.so use_authtok
password required pam_deny.so
session optional pam_keyinit.so revoke
session required pam_limits.so
-session optional pam_systemd.so
session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session required pam_unix.so
session optional pam_ldap.so
- /etc/sysconfig/authconfig
[root@localhost ~]# more /etc/sysconfig/authconfig
USELDAP=yes
USELDAPAUTH=yes
USELOCAUTHORIZE=yes
USESHADOW=yes
....
- /etc/ssh/sshd_config
[root@localhost ~]# cat /etc/ssh/sshd_config | grep UsePAM
# WARNING: 'UsePAM no' is not supported in Red Hat Enterprise Linux and may cause several
UsePAM yes
[root@localhost ~]#