ubuntu 18.04 安装ldap server

https://computingforgeeks.com/install-and-configure-openldap-server-ubuntu/

https://www.techrepublic.com/article/how-to-install-openldap-on-ubuntu-18-04/

请注意你需要把ellis.ldap.com 换成你想要的域名或者正确的域名

  1. 设置hostname
sudo hostnamectl set-hostname ellis.ldap.com
  1. 修改host文件
sudo vim /etc/hosts
192.168.214.131 ellis.ldap.com
  1. Install OpenLDAP Server on Ubuntu 22.04|20.04|18.04
sudo apt update
sudo apt -y install slapd ldap-utils

安装过程中会提示你设置ldap的admin 密码

  1. 运行以下命令,确认安装成功
sudo slapcat

显示如下

dn: dc=ldap,dc=com
objectClass: top
objectClass: dcObject
objectClass: organization
o: ldap.com
dc: ldap
structuralObjectClass: organization
entryUUID: 65094458-6ab7-103c-8f95-cd21456a8e2a
creatorsName: cn=admin,dc=ldap,dc=com
createTimestamp: 20220518053038Z
entryCSN: 20220518053038.430451Z#000000#000#000000
modifiersName: cn=admin,dc=ldap,dc=com
modifyTimestamp: 20220518053038Z

  1. Add base dn for Users and Groups
    The next step is adding a base DN for users and groups. Create a file named basedn.ldif with below contents:
vim basedn.ldif

dn: ou=people,dc=ldap,dc=com
objectClass: organizationalUnit
ou: people

dn: ou=groups,dc=ldap,dc=com
objectClass: organizationalUnit
ou: groups

请将ldap 以及com 替换成你的

Now add the file by running the command:

ldapadd -x -D cn=admin,dc=ldap,dc=com -W -f basedn.ldif
  1. 添加用户以及group
    Generate a password for the user account to add.
sudo slappasswd
vim ldapusers.ldif


dn: uid=ellis,ou=people,dc=ldap,dc=com
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: ellis
sn: ellis
givenName: ellis
cn: ellis
displayName: ellis
uidNumber: 10000
gidNumber: 5000
userPassword: {SSHA}ms3WJkFGn7T4sf8t59pgHqtmn2rnyVQU
gecos: FULLNAME
loginShell: /bin/bash
homeDirectory: /home/ellis

Replace computingforgeeks with the username to add
dc=ldap,dc=com with your correct domain values.
cn & sn with your Username Values
{SSHA}Zn4/E5f+Ork7WZF/alrpMuHHGufC3x0k with your hashed password

DEPARTMENT is a department or group you want to add.
SUBGROUP is a sub-group of the department.
USER is an actual user account on your system.
LASTNAME is the last name of the user.
FIRSTNAME is the first name of the user.
FULLNAME is the full name of the user.
DISPLAYNAME is the name you want displayed for the user.
USERDIRECTORY is the user’s home directory on the Linux server.

添加用户

ldapadd -x -D cn=admin,dc=ldap,dc=com -W -f ldapusers.ldif 

Do the same of group. Create ldif file:

vim ldapgroups.ldif

dn: cn=ellis,ou=groups,dc=ldap,dc=com
objectClass: posixGroup
cn: ellis
gidNumber: 1000
memberUid: ellis

添加group

ldapadd -x -D cn=admin,dc=ldap,dc=com -W -f ldapgroups.ldif
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值