- 基礎環境準備
- 關閉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就會自動建立了。