在CentOS 6.5上安装OpenLDAP并配置LDAP方式用户登录

1.安装PHP和apache

如果没有EPEL的源需要安装下

yum install epel-release

若没有下载下来,就创建/etc/yum.repo.d/epel.repo


[epel]

name=Extra Packages for Enterprise Linux 6 - $basearch

#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

[epel-debuginfo]

name=Extra Packages for Enterprise Linux 6 - $basearch - Debug

#baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch/debug

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-6&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1

[epel-source]

name=Extra Packages for Enterprise Linux 6 - $basearch - Source

#baseurl=http://download.fedoraproject.org/pub/epel/6/SRPMS

mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-source-6&arch=$basearch

failovermethod=priority

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

gpgcheck=1


phpldapadmin依赖apache和php

yum install php httpd

配置httpd.conf

2.安装OpenLDAP

yum install *openldap* openldap openldap-servers openldap-clients

配置OpenLDAP,配置文件/etc/openldap/slapd.conf

该文件默认没有,从/usr/share/openldap-servers/slapd.conf.obsolete拷贝一份到该位置

owner为ldap:ldap


database monitor

access to *

by dn.exact="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth" read

by dn.exact="cn=Manager,dc=iflyyun,dc=cn" read

by * none

database        bdb

suffix          "dc=iflyyun,dc=cn"

checkpoint      1024 15

rootdn          "cn=Manager,dc=iflyyun,dc=cn"


配置/etc/openldap/ldap.conf


BASE    dc=iflyyun,dc=cn

URI     ldap://bja-pro0002.hadoop.cpcc.iflyyun.cn


配置ldap管理员用户密码

sldappasswd(注意不要用ldappasswd,否则会报GSSAPI错误)

输入密码,获得{SSHA}ph+VRzfWSeamboy0itVlazrJrxzVHh80格式的密码再修改/etc/openldap/slapd.conf

直接使用明文密码,使用加密密码有点问题

配置apache识别index.php

修改/etc/httpd/conf/httpd.conf

找到下面这一行,添加index.php

DirectoryIndex index.html index.html.var index.php

修改/etc/httpd/conf.d/php.conf

测试OpenLDAP配置文件是否正确:

slaptest -u -f /etc/openldap/slapd.conf

3.安装phpldapadmin

yum install phpldapadmin

配置/etc/phpldapadmin/config.ini


$servers->setValue(‘server‘,‘host‘,‘192.168.51.211‘);

$servers->setValue(‘server‘,‘port‘,389);

$servers->setValue(‘server‘,‘base‘,array(‘dc=iflyyun,dc=cn‘));

$servers->setValue(‘login‘,‘auth_type‘,‘cookie‘);

$servers->setValue(‘login‘,‘bind_id‘,‘cn=Manager,dc=iflyyun,dc=cn‘);

$servers->setValue(‘login‘,‘attr‘,‘dn‘);(397行,这行取消注释)

// $servers->setValue(‘login‘,‘attr‘,‘uid‘);(将这行注释掉,否则登录会报错)


修改/etc/httpd/conf.d/phpldapadmin.conf,允许从其他机器访问


<Directory /usr/share/phpldapadmin/htdocs>

Order Deny,Allow

Allow from all

</Directory>


4.phpldapadmin配置

删除/etc/openldap/lapd.d/目录下的所有文件

创建LDAP根目录

ldapadd -x -D"cn=Manager,dc=iflyyun,dc=cn" -f base.ldif -W

base.ldif


dn: dc=iflyyun,dc=cn

o: ldap

objectclass: dcObject

objectclass: organization


创建管理员用户

# Manager, iflyyun.cn

dn: cn=Manager,dc=iflyyun,dc=cn

objectClass: simpleSecurityObject

objectClass: organizationalRole

cn: Manager

description: LDAP administrator

5.LDAP客户端配置

安装必备软件

yum install nss-pam-ldapd pam_ldap openldap-clients

需要修改的配置文件有:

/etc/sysconfig/authconfig、/etc/pam.d/system-auth、/etc/openldap/ldap.conf、/etc/nssswitch.conf

修改/etc/sysconfig/authconfig


IPADOMAINJOINED=no

USEMKHOMEDIR=yes

USEPAMACCESS=no

CACHECREDENTIALS=yes

USESSSDAUTH=no

USESHADOW=yes

USEWINBIND=no

USEDB=no

FORCELEGACY=no

USEFPRINTD=yes

FORCESMARTCARD=no

PASSWDALGORITHM=yes

USELDAPAUTH=yes

USEPASSWDQC=no

IPAV2NONTP=no

USELOCAUTHORIZE=yes

USECRACKLIB=yes

USEIPAV2=no

USEWINBINDAUTH=no

USESMARTCARD=no

USELDAP=yes

USENIS=no

USEKERBEROS=no

USESYSNETAUTH=yes

USESSSD=no

USEHESIOD=no


修改/etc/pam.d/system-auth


#%PAM-1.0

# This file is auto-generated.

# User changes will be destroyed the next time authconfig is run.

auth        required      pam_env.so

auth        sufficient    pam_fprintd.so

auth        sufficient    pam_ldap.so

auth        sufficient    pam_unix.so nullok try_first_pass

auth        requisite     pam_succeed_if.so uid >= 500 quiet

auth        required      pam_deny.so

account     required      pam_unix.so

account     sufficient    pam_localuser.so

account     sufficient    pam_succeed_if.so uid < 500 quiet

account     required      pam_permit.so

account     required      pam_ldap.so

password    requisite     pam_cracklib.so try_first_pass retry=3 type=

password    sufficient    pam_unix.so md5 shadow nullok try_first_pass use_authtok

password    sufficient    pam_ldap.so  use_authtok md5

password    required      pam_deny.so

session     optional      pam_keyinit.so revoke

session     required      pam_limits.so

session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid

session     required      pam_unix.so

session     required   pam_mkhomedir.so skel=/etc/skel/ umask=0022

session     optional   pam_ldap.so


修改/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

TLS_CACERTDIR /etc/openldap/cacerts

BASE dc=iflyyun,dc=cn

URI ldap://hfa-pro0002.hadoop.cpcc.iflyyun.cn


修改/etc/nssswitch.conf


#

# /etc/nsswitch.conf

#

# An example Name Service Switch config file. This file should be

# sorted with the most-used services at the beginning.

#

# The entry ‘[NOTFOUND=return]‘ means that the search for an

# entry should stop if the search in the previous entry turned

# up nothing. Note that if the search failed due to some other reason

# (like no NIS server responding) then the search continues with the

# next entry.

#

# Valid entries include:

#

#       nisplus                 Use NIS+ (NIS version 3)

#       nis                     Use NIS (NIS version 2), also called YP

#       dns                     Use DNS (Domain Name Service)

#       files                   Use the local files

#       db                      Use the local database (.db) files

#       compat                  Use NIS on compat mode

#       hesiod                  Use Hesiod for user lookups

#       [NOTFOUND=return]       Stop searching if not found so far

#

# To use db, put the "db" in front of "files" for entries you want to be

# looked up first in the databases

#

# Example:

#passwd:    db files nisplus nis

#shadow:    db files nisplus nis

#group:     db files nisplus nis

passwd:     files ldap

shadow:     files ldap

group:      files ldap

#hosts:     db files nisplus nis dns

hosts:      files dns

# Example - obey only what nisplus tells us...

#services:   nisplus [NOTFOUND=return] files

#networks:   nisplus [NOTFOUND=return] files

#protocols:  nisplus [NOTFOUND=return] files

#rpc:        nisplus [NOTFOUND=return] files

#ethers:     nisplus [NOTFOUND=return] files

#netmasks:   nisplus [NOTFOUND=return] files

bootparams: nisplus [NOTFOUND=return] files

ethers:     files

netmasks:   files

networks:   files

protocols:  files

rpc:        files

services:   files

netgroup:   nisplus

publickey:  nisplus

automount:  files nisplus

aliases:    files nisplus


开启名称缓存服务

service nscd restart

参考

http://www.centoscn.com/image-text/config/2013/0819/1367.html

http://bbs.linuxtone.org/home.php?mod=space&uid=12643&do=blog&id=3438

http://www.ibm.com/developerworks/cn/linux/l-openldap/#listing18

https://www.centos.org/docs/5/html/Deployment_Guide-en-US/s1-ldap-quickstart.html

http://54im.com/openldap/centos-6-yum-install-openldap-phpldapadmin-tls-%E5%8F%8C%E4%B8%BB%E9%85%8D%E7%BD%AE.html

时间: 2024-08-06 20:07:19

在CentOS 6.5上安装OpenLDAP并配置LDAP方式用户登录的相关文章

在Linux CentOS 6.6上安装Python 2.7.9

在Linux CentOS 6.6上安装Python 2.7.9 CentOS 6.6自带的是Python 2.6.6,而编译llvm需要Python 2.7以上. checking for python... /usr/bin/python checking for python >= 2.7... not found configure: error: found python 2.6.6 (/usr/bin/python); required >= 2.7 yum中最新的也是Python

在CentOS 6.4上安装Puppet配置管理工具

在CentOS 6.4上安装Puppet配置管理工具 linux, puppetAdd comments 五052013 上篇说了下在ubuntu12.04上安装puppet,安装的版本为puppet2.7.11版本,今天尝试了下在CentOS6.4系统上安装puppet 3.1.1版本,本文参考chenshake的文章 ? 1 2 3 4 OS:centso 6.4 X64 Puppet 3.1.1 Puppet master: master.canghai.com Puppet client

CentOS 6.5上安装docker与docker对中文字符集的支持

一.CentOS 6.5上安装docker 在CentOS 6.5 还不能够直接通过yum install -y docker 来安装docker服务 在一些文档中有看到说是因为内核太低的原因导致的,因为docker至少要做3.8以上的版本才能安装, 但是我发现其实并不需要升级内核就可以实现docker的安装不过,也有可能我的安装存在偶然性, 但是我还是记录一下,以防日后忘记. 1.先查看下你的系统内核是多少 # uname -r 2.6.32-431.el6.x86_64 我的是CentOS

CentOS 6.9上安装mysql-5.6.37

CentOS 6.9上安装mysql-5.6.37 1.准备数据存放的文件系统 新建一个逻辑卷,并将其挂载至特定目录即可.这里不再给出过程. 这里假设其逻辑卷的挂载目录为/data,而后需要创建/data/mysqldata目录做为mysql数据的存放目录. [[email protected] /]# mkdir -p /data/mysqldata 2.新建用户以安全方式运行进程: [[email protected] ~]# useradd mysql -s /sbin/nologin -

如何在CentOS 5.5上安装ruby 1.8.7

原文链接:http://heatware.net/linux-unix/how-to-install-ruby-1-8-7-centos-5-5/ 你曾经试过在CentOS 5.5上面运行 yum install ruby 命令吗?如果你使用的是默认的应用库配置,你会发现你安装的是老版本的Ruby 1.8.5.如果你还没有准备好升级到Ruby 1.9,而是准备安装Ruby 1.8.7,请往下看! 1 yum install -y gcc zlib zlib-devel 2 wget ftp://

CentOS 5.3上安装Apache+php+Mysql+phpMyAdmin

1.系统下载CentOS 开发社区已发布了新的 5.3 版本.CentOS 5.3 基于 Red Hat Enterpris Linux 5.3.0,其中包括 Kernel 2.6.18.Apache 2.2.PHP 5.1.6.MySQL 5.0.PostgreSQL 8.GNOME 2.16.KDE 3.5.OpenOffice.org 2.3.Firefox 3.0.Evolution 2.12 等等.此外,CentOS 5.3 更新了美工设计,并根据用户的请求恢复了 Contrib 仓库

在vmware player 下的centos 6.5上安装xfce4

Xfce是linux系统下的一个桌面环境,安装方法如下: 利用系统自带的yum源,找不到xfce,更新yum源, #wget http://mirrors.ustc.edu.cn/epel/6Server/x86_64/epel-release-6-8.noarch.rpm #rpm -ivh epel-release-6-8.noarch.rpm #yum search xfce4 #yum groupinfo Xfce #yum groupinstall Xfce #yum install

CentOS 6.5上安装GlassFish4.0 过程笔记

CentOS 6.5上安装GlassFish4.0 过程笔记 1.安装JDK, 注意操作系统的位数, 64 or 32: [[email protected] ~]# mkdir /usr/java  [[email protected] ~]# cd /usr/java[[email protected] java]#rpm -Uvh /bak/jdk-7u55-linux-x64.rpm  [[email protected] java]# JAVA_HOME=/usr/java/jdk1.

如何在CentOS 5/6上安装EPEL源

原文:http://os.51cto.com/art/201312/420725.htm 如何在CentOS 5/6上安装EPEL源 2013-12-04 14:45 译者:NearTan Linux中国 字号:T | T 我们可以很容易地通过yum命令从EPEL源上获取上万个在CentOS自带源上没有的软件.在文本中,我将展示在CentOS下如何安装EPEL源. AD: EPEL 是什么? EPEL (Extra Packages for Enterprise Linux,企业版Linux的额