- 基础环境准备
- 关闭sssd及安装nslcd客户端
- 配置nslcd客户端
- 启动nslcd进程
- 客户端验证
- ssh登陆自动建立家目录
本文承接openldap服务端安装配置,基础环境请参考openldap服务端安装配置shell
关闭sssd进程,因为我这最小化安装,并无sssd进程vim
[root@mldap01 ~]# service sssd stop && chkconfig sssd off sssd: unrecognized service
安装OpenLDAP客户端软件包
shell [root@test01 ~]# yum -y install openldap-clients nss-pam-ldapd
bash
修改nslcd.conf配置文件,该文件是由nss-pam-ldapd包提供
shell [root@test01 ~]# vim /etc/nslcd.conf uri ldap://mldap01.gdy.com base dc=gdy,dc=com ssl no tls_cacertdir /etc/openldap/certs [root@test01 ~]# rpm -qf /etc/nslcd.conf nss-pam-ldapd-0.7.5-32.el6.x86_64
服务器
修改pam_ldap.conf配置文件,由pam_ldap包提供,pam_ldap
shell [root@test01 ~]# vim /etc/pam_ldap.conf base dc=gdy,dc=com uri ldap://mldap01.gdy.com ssl no tls_cacertdir /etc/openldap/certs bind_policy soft [root@test01 ~]# rpm -qf /etc/pam_ldap.conf pam_ldap-185-11.el6.x86_64
ssh
修改system-auth认证文件ui
由pam包提供(系统自带包)
shell [root@test01 ~]# rpm -qf /etc/pam.d/system-auth pam-1.1.1-24.el6.x86_64
3d
修改nsswitch.conf配置文件rest
修改authconfig文件
shell [root@test01 ~]# rpm -qf /etc/sysconfig/authconfig authconfig-6.1.12-23.el6.x86_64 [root@test01 ~]# vim /etc/sysconfig/authconfig USESHADOW=yes USELDAPAUTH=yes USELOCAUTHORIZE=yes USELDAP=yes
code
选项解释以下
shell USESHADOW=yes //启用密码验证 USELDAPAUTH=yes //启用OpenLDAP验证 USELOCAUTHORIZE=yes //启用本地验证 USELDAP=yes //启用LDAP认证协议
blog
[root@test01 ~]# /etc/init.d/nslcd restart Stopping nslcd: [FAILED] Starting nslcd: [ OK ] [root@test01 ~]# chkconfig nslcd on [root@test01 ~]# chkconfig --list nslcd nslcd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
使用id
命令或getent
命令验证
[root@test01 ~]# getent passwd user1 user1:x:501:501:user1:/home/user1:/bin/bash [root@test01 ~]# id user1 uid=501(user1) gid=501(user1) groups=501(user1) [root@test01 ~]# cat /etc/passwd | grep user1
使用ssh
登陆验证
[root@test01 ~]# ssh user1@127.0.0.1 The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established. RSA key fingerprint is 1a:8a:57:12:ee:68:91:a4:bd:c5:48:f1:03:a9:5f:9c. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '127.0.0.1' (RSA) to the list of known hosts. user1@127.0.0.1's password: Could not chdir to home directory /home/user1: No such file or directory -bash-4.1$
把/etc/ssh/sshd_config中的UsePAM设置成yes
在/etc/pam.d/sshd添加最后一行,加入这行的目的是ssh首次登陆服务器时建立home目录
此时ssh登陆就会发现会自动建立home目录,而且权限为0700。
修改/etc/pam.d/password-auth
这个仍是须要加上,虽然不知道什么意思。若是不加上,openldap 密码策略时那一块老是经过ssh登陆不上去。
重启sshd进程。最后不要忘记重启sshd进程。
修改system-auth认证文件,添加以下行。就搞定了。此时su - $user就会自动建立了。