天天看點

LDAP

參考網址:

http://blog.csdn.net/hitabc141592/article/details/22931179

http://blog.sina.com.cn/s/blog_64aac6750101gwst.html

網絡資源查找、使用者通路控制、認證資訊查詢、網絡安全、商務網的通用資料庫服務和安全服務。

目錄服務是一種特殊的資料庫系統,并專門針對讀取、浏覽、搜尋操作進行了特定的優化。

/etc/openldap/ldap.conf定義全局性的内容

拷貝配置檔案:/usr/share/openldap-servers/slapd.conf.obsolete

cp/usr/share/openldap-servers/slapd.conf.obsolete /etc/openldap/slapd.conf

建立管理者密碼:

 slappasswd

這裡我輸入的123456

{SSHA}WidKJ2k3LackYaz8cbOCatTgOOKmemua

slaptest  -f /etc/openldap/slapd.conf -F/etc/openldap/slapd.d

Serviceslapd restart

拷貝配置檔案:/usr/share/openldap-servers/DB_CONFIG.example

cp/usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG

Chmod640  /etc/openldap/slapd.conf

 chown ldap:ldap slapd.conf

重新開機服務

建立幾個使用者如:user1/user2/user3

安裝migrationtools.noarch軟體包

編輯檔案:

/usr/share/migrationtools/migrate_common.ph

# Default DNS domain

$DEFAULT_MAIL_DOMAIN= "my-domain.com";

# Default base

$DEFAULT_BASE ="dc=my-domain,dc=com";

./migrate_passwd.pl  /etc/passwd > /home/user.ldif

./migrate_group.pl/etc/group >/home/group.ldif

/usr/share/migrationtools/migrate_base.pl> /home/base.ldif

編輯三個檔案:

[root@victormigrationtools]# catexample.ldif

dn:dc=my-domain,dc=com

dc: my-domain

objectClass:dcObject

objectClass:organizationalUnit

ou: my-domain.com

[root@victormigrationtools]# catou_people.ldif

dn:ou=people,dc=my-domain,dc=com

ou: people

[root@victormigrationtools]# cat  ou_group.ldif

dn:ou=group,dc=my-domain,dc=com

ou: group

删除/etc/openldap/slapd.d

測試并生成配置檔案:

slaptest  -f/etc/openldap/slapd.conf -F /etc/openldap/slapd.d

chown -R ldap:ldap/etc/openldap/slapd.d

重新開機

修改所屬組:

/var/lib/ldap

/etc/openldap/

下面就要把這三個檔案導入到LDAP,這樣LDAP的資料庫裡就有了我們想要的使用者

 ldapadd -x -D"cn=Manager,dc=my-domain,dc=com" -W -f /home/base.ldif

ldapadd -x -D"cn=Manager,dc=my-domain,dc=com" -W -f /home/user.ldif

ldapadd -x -D"cn=Manager,dc=my-domain,dc=com" -W -f /home/group.ldif

重新開機slapd服務

測試:

Ldapsearch  -x -b "dc=my-domain,dc=com"

顯示以下資訊:

# user1, People,my-domain.com

dn:uid=user1,ou=People,dc=my-domain,dc=com

uid: user1

cn: user1

objectClass: account

objectClass:posixAccount

objectClass: top

objectClass:shadowAccount

userPassword::e2NyeXB0fSQ2JFRDMTIxU0pUJE5ldGxwSTZQTlJhdG5NeDVSd2o3RWh0WmdhZ2J

 KLmNjRjBHUGQ3UEhmWVdTOEdoYUhZbHZ0ZnZVWUF0aU5WZFhBTW9hOGJiTnkwdWNkeDRBQlRwNXUw

shadowLastChange:17216

shadowMin: 0

shadowMax: 99999

shadowWarning: 7

loginShell:/bin/bash

uidNumber: 501

gidNumber: 502

homeDirectory:/home/user1

二、安裝nfs

 yum install nfs*

/home/user1        *(rw,no_root_squash)

# service rpcbindrestart

# service nfs restart

三、LDAP用戶端的設定:

安裝LDAP client認證需要的pam包:

yum installnss-pam-ldapd pam_ldap -y 

LANG=Cauthconfig-tui這個需要安裝

authconfig

安裝sssd:

 yum install sssd

可以檢視本地系統資料庫或者LDAP資料庫中的資訊。例如getent passwd

一、使用這個指令: system-config-authentication

使用者目錄集中管理:

yum groupinstall 'directory client'

官方制作LDAP的文檔:

http://www.idevelopment.info/data/LDAP/LDAP_Resources/OPENLDAP_Configure_System_to_Authenticate_Using_OpenLDAP_CentOS5.shtml

centos提供了兩種接口來配置客戶系統認證

CentOSprovides two interfaces to configure client system authentication:

  • system-config-authentication -     (GUI)
  • authconfig - (CLI)

 二、使用:

authconfig

authconfig--enableldap --enableldapauth --ldapserver='ldap://192.168.2.6'--ldapbasedn='dc=my-domain,dc=com' --enablemkhomedir --enableshadow--enablelocauthorize --passalgo=sha256 --update

測試是否生效:

authconfig --test

getsebool -a | grepnfs_home

use_nfs_home_dirs--> on

檢查 sebool如果是 on那麼遠端使用者無法進入自己的目錄

setsebool -PVuse_nfs_home_dirs  0

/home/guests/etc/auto.ldap

cp /etc/auto.misc/etc/auto.ldap

Vi /etc/auto.ldap加入下面一行:

*192.168.2.6:/home/guests/&

service autofsreload

 查資料,然後自己安裝,配置,弄了一天沒弄出來,悲劇。。。。

繼續閱讀