- 论坛徽章:
- 0
|
现有多台LINUX服务器,每次给每台机器一一添加帐号都感觉好麻烦,于是就想用LDAP来做这个事情。
现搭建4台虚拟机测试 ldapmaster.example.com 192.168.1.200
ldapslave.example.com 192.168.1.201
ldapclient-a.example.com 192.168.1.202
ldapclient-b.example.com 192.168.1.203
设想ldapmaster.example.com做主认证服务器,ldapslave.example.com做从服务器。当主服务器挂掉时,从服务器能自动替代主服务器工作。
客户端与服务器端之间的传输采用的是TLS加密。
我这样来设置:
1.安装软件
主服务器ldapmaster上安装软件
openldap-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
openldap-servers-2.3.43-3.el5
nss_ldap-253-22.el5_4
python-ldap-2.2.0-2.1
openldap-clients-2.3.43-3.el5
openssl-0.9.8e-12.el5
从服务器ldapslave上安装软件
openldap-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
openldap-servers-2.3.43-3.el5
nss_ldap-253-22.el5_4
python-ldap-2.2.0-2.1
openldap-clients-2.3.43-3.el5
openssl-0.9.8e-12.el5
客户端ldapclient-a上安装软件
openldap-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
nss_ldap-253-22.el5_4
python-ldap-2.2.0-2.1
openldap-clients-2.3.43-3.el5
openssl-0.9.8e-12.el5
2.配置主服务器ldapmaster /etc/openldap/slapd.conf
############################################
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
#######################################################################
# ldbm and/or bdb database definitions
#######################################################################
database bdb
suffix "dc=example,dc=com"
rootdn "cn=root,dc=example,dc=com"
rootpw {SSHA}CMqHlrrV5RR9bA5icsi/6/7mJNvfVe4k
directory /var/lib/ldap
# Indices to maintain for this database
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub
# Replicas of this database
####与从服务器同步部分
replogfile /var/lib/ldap/openldap-master-replog
replica host=ldapslave.example.com:389
binddn="cn=root,dc=example,dc=com"
bindmethod=simple
credentials=secret
tls=yes
####TLS加密部分
TLSCipherSuite HIGH:MEDIUM:+SSLv2:+SSLv3:RSA
TLSCACertificateFile /etc/openldap/cacerts/server.pem
TLSCertificateFile /etc/openldap/cacerts/server.pem
TLSCertificateKeyFile /etc/openldap/cacerts/server.pem
TLSVerifyClient allow
#########################################
3.配置从服务器ldapslave /etc/openldap/slapd.conf
##################################################
include /etc/openldap/schema/core.schema
include /etc/openldap/schema/cosine.schema
include /etc/openldap/schema/inetorgperson.schema
include /etc/openldap/schema/nis.schema
allow bind_v2
pidfile /var/run/openldap/slapd.pid
argsfile /var/run/openldap/slapd.args
#######################################################################
# ldbm and/or bdb database definitions
#######################################################################
database bdb
suffix "dc=example,dc=com"
rootdn "cn=root,dc=example,dc=com"
rootpw {SSHA}CMqHlrrV5RR9bA5icsi/6/7mJNvfVe4k
directory /var/lib/ldap
index objectClass eq,pres
index ou,cn,mail,surname,givenname eq,pres,sub
index uidNumber,gidNumber,loginShell eq,pres
index uid,memberUid eq,pres,sub
index nisMapName,nisMapEntry eq,pres,sub
####与主服务器同步部分
updatedn "cn=root,dc=example,dc=com"
updateref ldap://ldapmaster.example.com:389/
####TLS配置部分
TLSCipherSuite HIGH:MEDIUM:+SSLv2:+SSLv3:RSA
TLSCACertificateFile /etc/openldap/cacerts/server.pem
TLSCertificateFile /etc/openldap/cacerts/server.pem
TLSCertificateKeyFile /etc/openldap/cacerts/server.pem
TLSVerifyClient allow
############################################
4.配置客户端ldapclient-a /etc/openldap/ldap.conf
#
# LDAP Defaults
#
# See ldap.conf(5) for details
# This file should be world readable but not world writable.
#BASE dc=example, dc=com
#URI ldap://ldap.example.com ldap://ldap-master.example.com:666
#SIZELIMIT 12
#TIMELIMIT 15
#DEREF never
BASE dc=example,dc=com
URI ldaps://ldapmaster.example.com/ ldaps://ldapslave.example.com/
TLS_CACERTDIR /etc/openldap/cacerts
以上配置用的TLS加密服务器和客户机之间的传输明文信息。现在有一个问题,就是在主服务器ldapmaster创建证书时,server.pem里包含了主服务器域名的信息ldapmaster.example.com,如果是客户机ldapclient-a去同主服务器之间去认证那自然是不会出现问题。如果主服务器DOWN了,从服务器接替主服务器工作的时候,客户机ldapclient-a去从服务器slave去获取认证的时候,由于server.pem里含有的是ldapmaster.example.com的信息,那么自然是通不过认证。
如果不做TLS加密的那也是不存在这样的问题。
我考虑过把ldapmaser.example.com解析成2个IP 192.168.1.200,192.168.1.201,这样就解决了证书的认证问题,但是这样的话,如果其中一台机器DOWN了之后,客户机去服务器认证的时候总会有50%的几率认证失败,这也达不到设置主从服务器认证的初衷。
请大家给点意见。谢谢。
LDAP以及TLS配置参考于 http://www.linuxhomenetworking.c ... ing_LDAP_and_RADIUS
master slave同步配置参考于 http://Linux.chinaitlab.com/administer/519684_ |
|