分类: LINUX
2011-10-23 13:38:20
管理
安装phpldapadmin比较方便一些。用LDAP管理passwd和group的信息。
在左侧的tree中点开ou=People分支,有一个“Create new entry here”
然后会出现templates
选择Generic User Account,填好信息,创建。
ssh colinli@10.107.100.148
colinli@10.107.100.148's password:
------------------------------------------------------------------------
UNAUTHORIZED ACCESS PROHIBITED
------------------------------------------------------------------------
This system is for the use of authorized users only. Individuals using
this computer system without authority, or in excess of their
authority, are subject to having all of their activities on this
system monitored and recorded by system personnel. In the course of
monitoring individuals improperly using this system, or in the
course of system maintenance, the activities of authorized users may
also be monitored. Anyone using this system expressly consents to such
monitoring and is advised that if such monitoring reveals possible
criminal activity, system personnel may provide the evidence of such
monitoring to law enforcement officials.
------------------------------------------------------------------------
Could not chdir to home directory /home/users/colinli: No such file or directory
-sh-3.2$ id
uid=1001 gid=500 groups=500
-sh-3.2$ id test
id: test: No such user
用root是可以看到UID和GID信息的,但是普通用户会只能显示数字信息和提示无此用户的提示,用tcpdump看了下,发现root输入id时候会有ldap查询流量,但是普通用户则没有,应该和权限有关,解决方法可以启动nscd这个缓存服务。
-sh-3.2$ sudo /etc/init.d/nscd start
Starting nscd: [ OK ]
-sh-3.2$ id
uid=1001(colinli) gid=500(cicit) groups=500(cicit)
-sh-3.2$ id test
uid=1000(test) gid=503(cicqa) groups=503(cicqa)
比如colinli默认是在cicit组。如果修改主组,直接在用户dn里面修改gid就可以了,但是附加组需要在Group中修改,比如把colinli加入cicqa组。
模板选择Posix Group
将用户选中然后更新就可以了。
用户需要再次登陆就可以看到更新后的组信息了。而nscd的信息需要等缓存失效重新读取时候才会刷新,这个时间在nscd.conf里面来设定。如果要立即刷新,可以手工运行/etc/init.d/nscd reload。
在登陆时候可以看到提示没有home目录的错误
Could not chdir to home directory /home/users/colinli: No such file or directory
这是因为用户是远程创建,所以没有建立home目录。
解决方法是在/pam.d/system-auth中添加
session required pam_mkhomedir.so
这样如果没有home目录会自动创建。
在Redhat里面是要在system-auth中而不是login中,否则不生效。
刚开始想的比较复杂,又是web方式又是shell script,其实最简单的就是passwd
[colinli@cic-int-hdkwebui-301 ~]$ passwd
Changing password for user colinli.
Enter login(LDAP) password:
New UNIX password:
Retype new UNIX password:
LDAP password information changed for colinli
passwd: all authentication tokens updated successfully.
[colinli@cic-int-hdkwebui-301 ~]$ ssh localhost
Warning: Permanently added 'localhost' (RSA) to the list of known hosts.
colinli@localhost's password:
Last login: Sun Oct 23 13:00:11 2011 from 10.109.0.216
$
使用phpldapadmin创建帐号时,home目录默认为/home/users/uid,而shell只能选/bin/sh, /bin/sh和/bin/tsh,这样bash_profile就不会执行。
修改/var/www/html/phpldapadmin/templates/creation/posixAccount.xml
将/home/users替换成/home
修改loginshell,添加shell类型。
就可以了。
参考文档