基于LinuxOPENldap实验之账户管理

简介:
 
在linux下使用轻量级目录访问协议(LDAP)构建集中的身份验证系统可以减少管理成本,增强安全性,避免数据复制的问题。本实验是演示如何配置服务器和客户机OPENldap服务的。
实验环境:VMWare虚拟机下Red Hat Linux 企业版5.4 两台
准备工作:两台虚拟机分别为服务器和客户机。在服务器端安装openldap-servers软件包,在客户端安装openldap-clients软件包。
在该文档中,为了节约时间,所有试验步骤均摘自实验代码。还请各位朋友见谅!
1、 切换到/usr/share/openldap/migration/目录下,来编辑migrate_common.ph文件,
修改71、72行如下内容:
[root@ldap ~]# cd /usr/share/openldap/migration/
[root@ldap migration]# vim migrate_common.ph
70 # Default DNS domain
71 $DEFAULT_MAIL_DOMAIN = "example.com";
72
73 # Default base
74 $DEFAULT_BASE = "dc=example,dc=com";
2、在服务器端添加linuxtro1和linuxtro2两个用户,并添加密码为redhat
[root@ldap ~]# useradd linuxtro1 && echo redhat | passwd --stdin linuxtro1
Changing password for user linuxtro1.
passwd: all authentication tokens updated successfully.
[root@ldap ~]# useradd linuxtro2 && echo redhat | passwd --stdin linuxtro2
Changing password for user linuxtro2.
passwd: all authentication tokens updated successfully.
3、在/root/下创建ldap目录,用于存放条目文件。
[root@ldap ~]# mkdir /root/ldap
[root@ldap ~]# cd /usr/share/openldap/migration/
4、迁移base.ldif 、passwd.ldif和group.ldif文件,这个步骤有顺序,必须先迁移bash.ldif文件
[root@ldap migration]# ./migrate_base.pl > /root/ldap/base.ldif
[root@ldap migration]# tail -2 /etc/passwd > /tmp/passwd
[root@ldap migration]# tail -2 /etc/group > /tmp/group
[root@ldap migration]# ./migrate_passwd.pl /tmp/passwd /root/ldap/passwd.ldif
[root@ldap migration]# ./migrate_group.pl /tmp/group /root/ldap/group.ldif
[root@ldap migration]# cd /root/ldap/
[root@ldap ldap]# ll
total 24
-rw-r--r-- 1 root root 1200 Mar 31 18:57 base.ldif
-rw-r--r-- 1 root root 270 Mar 31 18:59 group.ldif
-rw-r--r-- 1 root root 722 Mar 31 18:59 passwd.ldif
5、分别将base.ldif、passwd.ldif和group.ldif文件导入到ldap中去。
[root@ldap ldap]# ldapadd -D "cn=Manager,dc=example,dc=com" -W -x -f base.ldif
Enter LDAP Password:
adding new entry "dc=example,dc=com"
adding new entry "ou=Hosts,dc=example,dc=com"
adding new entry "ou=Rpc,dc=example,dc=com"
adding new entry "ou=Services,dc=example,dc=com"
adding new entry "nisMapName=netgroup.byuser,dc=example,dc=com"
adding new entry "ou=Mounts,dc=example,dc=com"
adding new entry "ou=Networks,dc=example,dc=com"
adding new entry "ou=People,dc=example,dc=com"
adding new entry "ou=Group,dc=example,dc=com"
adding new entry "ou=Netgroup,dc=example,dc=com"
adding new entry "ou=Protocols,dc=example,dc=com"
adding new entry "ou=Aliases,dc=example,dc=com"
adding new entry "nisMapName=netgroup.byhost,dc=example,dc=com"
[root@ldap ldap]# ldapadd -D "cn=Manager,dc=example,dc=com" -W -x -f group.ldif
Enter LDAP Password:
adding new entry "cn=linuxtro1,ou=Group,dc=example,dc=com"
adding new entry "cn=linuxtro2,ou=Group,dc=example,dc=com"
[root@ldap ldap]# ldapadd -D "cn=Manager,dc=example,dc=com" -W -x -f passwd.ldif
Enter LDAP Password:
adding new entry "uid=linuxtro1,ou=People,dc=example,dc=com"
adding new entry "uid=linuxtro2,ou=People,dc=example,dc=com"
6、切换到客户端来登录一下,首先要配置一下客户端启用LDAP。
在命令行下输入setup,会弹出图形界面,选择第一个选项。
clip_image001
选择“Use LDAP”和“Use LDAP Authentication”认证方式,点击“Next”,进入下一步。
clip_image003
在Server一栏中填入LDAP服务器的IP地址,ldap://192.168.0.43
Base DN一栏中填入dc=example,dc=com
clip_image004
7、实验结果显示,可以登陆成功,但是令人遗憾的是登录后没有家目录,那么该如何来解决这个问题呢?
clip_image005
clip_image006
可以尝试查询一下linuxtro1的信息,可以正常显示。
clip_image008
8、回到服务器接着做如下的配置:
编辑nismap.ldif文件,添加如下内容,完成后保存退出。
[root@ldap ~]# vim nismap.ldif
dn: nisMapName=auto.master,dc=example,dc=com
objectClass: top
objectClass: nisMap
nisMapName: auto.master
dn: cn=/home,nisMapName=auto.master,dc=example,dc=com
objectClass: top
objectClass: nisObject
cn: /home
nisMapName: auto.master
nisMapEntry: ldap://192.168.0.43:nisMapName=auto.home,dc=example,dc=com
dn: nisMapName=auto.home,dc=example,dc=com
objectClass: top
objectClass: nisMap
nisMapName: auto.home
dn: cn=linuxtro1,nisMapName=auto.home,dc=example,dc=com
objectClass: top
objectClass: nisObject
cn: linuxtro1
nisMapName: auto.home
nisMapEntry: -rw,soft,intr 192.168.0.43:/home/linuxro1
dn: cn=linuxtro2,nisMapName=auto.home,dc=example,dc=com
objectClass: top
objectClass: nisObject
cn: linuxtro2
nisMapName: auto.home
nisMapEntry: -rw,soft,intr 192.168.0.43:/home/linuxtro2
9、将条目文件添加到LDAP中去。
[root@ldap ~]# ldapadd -D "cn=Manager,dc=example,dc=com" -W -x -f nismap.ldif
Enter LDAP Password:
adding new entry "nisMapName=auto.master,dc=example,dc=com"
adding new entry "cn=/home,nisMapName=auto.master,dc=example,dc=com"
adding new entry "nisMapName=auto.home,dc=example,dc=com"
adding new entry "cn=linuxtro1,nisMapName=auto.home,dc=example,dc=com"
adding new entry "cn=linuxtro2,nisMapName=auto.home,dc=example,dc=com"
10、编辑/etc/exports文件,添加如下两行,并保存退出。
[root@ldap ~]# vim /etc/exports
/home/linuxtro1 192.168.0.43/24(rw,sync)
/home/linuxtro2 192.168.0.43/24(rw,sync)
11、启动nfs服务。
[root@ldap ~]# service nfs start
Starting NFS services: [ OK ]
Starting NFS quotas: [ OK ]
Starting NFS daemon: [ OK ]
Starting NFS mountd: [ OK ]
[root@ldap ~]# chkconfig nfs on
[root@ldap ~]#
12、切换到LDAP客户端,编辑/etc/auto.master文件,添加如下一行内容。
[root@linuxtro ~]# vim /etc/auto.master
/home ldap:192.168.0.43:nisMapName=auto.home,dc=example,dc=com
重启autofs 服务。
[root@linuxtro ~]# service autofs restart
Stopping automount: [ OK ]
Starting automount: [ OK ]
13、再次切换到客户端上重新登录LDAP服务器。查看登录时是否有家目录。
clip_image009
好了,在客户端可也看到家目录了,来庆祝一下吧!!到此为止,基于LinuxOPENldap实验之账户管理就配置完成了。









本文转自 linuxtro 51CTO博客,原文链接:http://blog.51cto.com/linuxtro/290502,如需转载请自行联系原作者
目录
相关文章
|
9月前
|
SQL 数据库连接 数据库
学生信息登录系统总结一
在敲学生系统的时候,进行登录学生管理学生信息登录,当时就是出师不利,还没有进入主界面就被卡在外面直接坐上了冷板凳,没想到道路刚开始就是如此坎坷,频繁报错那么就列举出3个具有代表性的问题,这个问题也是困扰了我许久,一直得不到解决,还是老办法站在巨人的肩膀上,通过查阅资料那些前辈们的的博客也是知道,不光自己也是遇到了类似的问题,通过借鉴大神的们的博客总结,让自己也是有了信心,感觉自己也能解决,但是事与愿违,往往想的都是很美好的,现实很残酷,跌宕起伏,排山倒海,猛龙过江,心情跟做过山车一样。
53 0
|
存储 JSON 安全
实际项目教学:身份/权限验证
实际项目教学:身份/权限验证
170 0
实际项目教学:身份/权限验证
【自然框架】之通用权限的Demo(二):添加人员、添加账户、添加角色里面的账户以及列表的权限验证
      看了一下上一次发Demo的日期6月15日,已经过了半个多月,这个速度也实在是太慢了。还是心情的原因,恩,心理承受能力太弱了,哈哈。不过还是要坚持的,要继续下去。       还是先说一下这次的Demo里增加的内容吧。
838 0
|
SQL Web App开发 数据安全/隐私保护
后台登录——实验吧
刚刚做了实验吧的题目,现在整理一下 写出解题思路,希望能够帮助到那些需要帮助的人 所有的wp都是以一题一篇的形式写出 主要是为了能够让读者更好的阅读以及查找, 希望你们不要责怪!!共勉!!!   后台登录分值:10 来源: 实验吧 难度:易 参与人数:6632人 G...
1747 0
|
Web App开发 数据安全/隐私保护 数据格式
|
内存技术 数据安全/隐私保护