·首页 ·Linux ·新闻 ·论坛 ·博客 ·空间 ·存储  
ChinaUnix >> AIX用户俱乐部 >> 正文 AIX论坛 | AIX博客
 
使用Directory Server进行Linux用户验证
2006-03-05 10:42:37 作者:Ming Xia 来自:http://www-128.ibm.com
 
本文介绍如何使用 IBM Directory Server 进行 Linux 用户验证。作者循序渐进地介绍了如何对 Directory Server 和 Linux 进行配置,以实现一个使用 Directory Server 对 Linux 用户进行验证的基本配置。

简介
轻量级目录访问协议 (Lightweight Directory Access Protocol,LDAP) 是一个轻量级的客户机-服务器协议,用于访问目录服务,尤其是那些基于 X.500 的服务。IBM Directory Server 是一个实现 LDAP 协议的成熟产品。近来流行的 Linux 提供了一些系统用户验证方法,包括本地文件、NIS、LDAP 和 PAM 机制。Linux 可以为不同的服务使用不同的验证方法。

本文介绍了如何使用 IBM Directory Server 进行 Linux 用户验证。我没有在文中介绍相关的概念; 参考资料 中有相关的背景资料。

我要管理的 Linux 系统为 RedHat Linux 7.3,LDAP 服务器是 IBM Directory Server 5.1。如果需要,请参考 RedHat 和 IBM 的网站提供的 Linux 和 Directory Server 5.1 安装说明。

配置 Directory Server 5.1 服务器
在使用 Directory Server 来存储您的 Linux 系统用户信息之前,您需要先计划您的系统用户结构。例如,我将 Directory Server 5.1 服务器安装在一个单独的 Windows 2000 服务器上,计划了如下的系统用户结构:


o=ibm,c=cn
|-ou=csdl,o=ibm,c=cn
  |-ou=gcl,ou=csdl,o=ibm,c=cn
     |-uid=user1,ou=gcl,ou=csdl,o=ibm,c=cn
     |-uid=user2,ou=gcl,ou=csdl,o=ibm,c=cn

使用以下步骤来构建这个结构:

  1. 添加后缀。停止 Directory Server 服务器,然后使用 ldapxcfg 添加一个新的后缀: o=ibm,c=cn ,参见 图 1

    图 1. 添加一个新后缀

  2. 导入 LDAP Data Interchange Format (LDIF) 文件,以及基本结构。编辑 LDIF 文件,它定义了根专有名称 (distinguished name,DN) 和基本结构 DN,如下所示。
    
        version: 1 
            
        dn: o=IBM,c=CN
        objectclass: top
        objectclass: organization
        o: ibm
                
        dn: ou=CSDL,o=ibm,c=cn
        ou: CSDL
        objectclass: organizationalUnit
        objectclass: top
        description: China Software Development Lab
        businessCategory: R&D
               
        dn: ou=GCL,ou=CSDL,o=ibm,c=cn
        ou: GCL
        objectclass: organizationalUnit
        objectclass: top
        description: Globalization Certification Lab
    

    使用 ldapxcfg 导入 LDIF,参见 图 2

    图 2.

  3. 使用 Web 工具 ldif2db 来添加用户。创建一个新用户条目有两种不同的方法:
    Web 工具
    Directory Server 5.1 提供了一个 Web 应用程序,可以部署到特定的应用程序服务器上。它默认使用 WebSphere Application Server 5.0 express。这个工具为用户提供了一个友好的界面来帮您管理 LDAP 信息。
    命令行工具
    使用 ldif2db 来导入条目。例如,
    ldif2db -i oneEntry.ldif

    下面的这个例子介绍了如何使用命令工具来添加一个新用户。

    
    #oneEntry.ldif
             
    dn: uid=user1,ou=GCL,ou=CSDL,o=ibm,c=cn
    loginShell: /bin/bash
    memberUid: 900
    gidNumber: 800
    objectclass: posixGroup
    objectclass: top
    objectclass: posixAccount
    objectclass: shadowAccount
    uid: user1
    uidNumber: 900
    cn: user1
    description: One user of system
    homeDirectory: /home/user1
    userpassword: password
    ownerpropagate: TRUE
    entryowner: access-id:UID=USER1,OU=GCL,OU=CSDL,O=IBM,C=CN
    

    对于 Linux 用户信息,对象类应该是 posixAccount 。将本条目的 entryowner 设置为用户“自己”,这样用户就可以修改密码。要了解更多关于 Directory Server ACL 的信息,请阅读 Directory Server 文档。

添加用户完成后,启动 Directory Server 服务器来开始为 Linux 用户验证服务。

Linux 上的配置
在 RedHat Linux 7.3 上,以 root 身份登录,确保已经安装了以下两个软件包:

  • openldap-2.0.23-4
  • nss_ldap-185-1
使用 #rpm -qa|grep ldap 命令来检查已安装的 RPM。如果没有安装这两个软件包,那么挂载 RedHat 安装映像并执行以下命令:
 
  #rpm -ivh <PathToPkgs>/openldap-2.0.23-4.rpm
  #rpm -ivh <PathToPkgs>/nss_ldap-185-1.rpm

两个软件包安装完成后,打开 /etc/ldap.conf 文件来做一些配置。下面是一些用于配置的关键指令。

host 指定 LDAP 服务器 IP/主机名
base 指定 LDAP 客户机搜索起点
port 指定 LDAP 服务器端口
pam_filter 指定 LDAP 客户机搜索过滤器
pam_login_attribute 指定一个用户条目的登录属性
pam_password 指定客户机密码哈希方法

下面的例子是 ldap.conf 文件的部分内容。尤其注意那些 加粗的指令。

 
      # @(#)$Id: ldap.conf,v 1.24 2001/09/20 14:12:26 lukeh Exp $
      #
      # This is the configuration file for the LDAP nameservice
      # switch library and the LDAP PAM module.
      #
      # PADL Software
      # http://www.padl.com
      #
      # Your LDAP server. Must be resolvable without using LDAP.
      #host 127.0.0.1
      
        host 192.168.0.188
      
      # The distinguished name of the search base.
      #base dc=example,dc=com
      
        base o=IBM,c=CN
      
      # Another way to specify your LDAP server is to provide an
      # uri with the server name. This allows to use
      # Unix Domain Sockets to connect to a local LDAP Server.
      #uri ldap://127.0.0.1/
      #uri ldaps://127.0.0.1/ 
      #uri ldapi://%2fvar%2frun%2fldapi_sock/
      # Note: %2f encodes the '/' used as directory separator
      # The LDAP version to use (defaults to 3
      # if supported by client library)
      #ldap_version 3
      
      # The distinguished name to bind to the server with.
      # Optional: default is to bind anonymously.
      #binddn cn=proxyuser,dc=example,dc=com
     
      # The credentials to bind with. 
      # Optional: default is no credential.
      
      # The distinguished name to bind to the server with
      # if the effective user ID is root. Password is
      # stored in /etc/ldap.secret (mode 600)
      #rootbinddn cn=manager,dc=example,dc=com
      
      # The port.
      # Optional: default is 389.
      
        port 389
      
      # The search scope.
      #scope sub
      #scope one
      #scope base
      # Search timelimit
      #timelimit 30
      # Bind timelimit
      #bind_timelimit 30
      # Idle timelimit; client will close connections
      # (nss_ldap only) if the server has not been contacted
      # for the number of seconds specified below.
      #idle_timelimit 3600
      
      # Filter to AND with uid=%s
      
        pam_filter objectclass=posixAccount
      
      # The user ID attribute (defaults to uid)
      
        pam_login_attribute uid
      
      # Search the root DSE for the password policy (works
      # with Netscape Directory Server)
      #pam_lookup_policy yes
      # Check the 'host' attribute for access control
      # Default is no; if set to yes, and user has no
      # value for the host attribute, and pam_ldap is
      # configured for account management (authorization)
      # then the user will not be allowed to login.
      #pam_check_host_attr yes
      # Group to enforce membership of
      #pam_groupdn cn=PAM,ou=Groups,dc=example,dc=com
      # Group member attribute
      #pam_member_attribute uniquemember
      # Specify a minium or maximum UID number allowed
      #pam_min_uid 0
      #pam_max_uid 0
      # Template login attribute, default template user
      # (can be overriden by value of former attribute
      # in user's entry)
      #pam_login_attribute userPrincipalName
      #pam_template_login_attribute uid
      #pam_template_login nobody
      # HEADS UP: the pam_crypt, pam_nds_passwd,
      # and pam_ad_passwd options are no
      # longer supported.
      
      # Do not hash the password at all; presume
      # the directory server will do it, if
      # necessary. This is the default.
      #pam_password md5
     
        pam_password clear
      ssl no
      ... 
      ... 

      

保存所作的修改,然后使用 authconfig 来启用 LDAP 验证,即执行 #authconfig

在 User Information Configuration 面板中,参见 图 3,选中 Cache InformationUse LDAP。

图 3. User Information Configuration

在 Authentication Configuration 面板中,选中 Use LDAP Authentication,参见 图 4

图 4. Authentication Configuration

然后输入 Ok。Linux 系统将开始启用 LDAP 验证。

这个工具将会把指令 pam_password 的值设置为 md5。为了让用户可以成功地修改密码,您需要手工将这个指令值设置为“clear”。

现在我们可以作为信息存储在 Directory Server 服务器上的用户来登录了。例如,以 user1 的身份登录:


因为没有 user1 的主目录,所以登录 shell 自动将目录切换到“/”。为方便起见我们可以手工添加用户主目录:

  
  #mkdir /home/user1
  #cp /etc/skel/.* /home/user1
  #chown -R user1:user1 /home/user1

现在再次以 user1 身份登录,不再出现警告:


OK,好极了! 我们已经实现了一个基本的配置,可以利用 Directory Server 来对 Linux 系统用户进行验证。因为 Linux 和 Directory Server 都支持 Secure Sockets Layer (SSL),所以我们可以做更深入的配置以提高系统的安全性。关于 SSL 配置的更多信息,请参阅 参考资料

参考资料

关于作者
Ming Xia 毕业于上海华东师范大学,于 2000 年 7 月获得计算机科学学士学位。 他是 IBM 的签约人,在有关 GB18030 认证考试的 Globalization Certification Lab 中工作。他主要感兴趣的是 Linux 以及 Linux 与 IBM 产品之间的交互,他还投入大量的时间进行基于 Rational 工具的软件工程研究和 J2EE 的学习。可以通过 gclprj3@cn.ibm.com 与 Ming 联系。


原文链接:http://www-128.ibm.com/developerworks/cn/linux/l-ibmd/
 发表评论 | 查看评论
 
 
    

 网友交流更多>> 
· 急!P570无法启动,前面板报错B..
· I/O瓶颈问题?
· 主机液晶面板显示10011BOB错误,..
· 重装需要注意哪些问题细节
· 大家帮分析下AIX的售前好还是售..
· hacmp中db2的进程监控脚本要怎么..
· HMC 的区别?
· 谁动了我的文件?
· 170 跟150 2台机器,靠自带的CO..
· 关于 tar 命令的高级使用
· 购买150
· vmstat分析
· 关于nfs的问题
· 根据时间删除的脚本
· HA启动问题
· smitty install 异常中断....
· 准备买台学习机,有几个问题请教..
· 备份环境的尴尬.....
· 如何查看是否安装了GB18030字符..
· 223学习中,哪里有免费的AIX主机..
· aix5.3有个硬盘报错,哪位达人给..
· AIX 7026-6H1 硬盘报错
· 怎麽升级HACMP啊?
· 如何建立Aix的超级用户?
· lslpp -l 输出为什么是这样?
· 想修改persistent IP
· 怎麽给一个分区装操作系统啊?
· mirrorvg 时出的奇怪问题
· 关于文件系统的奇怪事情
· f85电源灯闪烁,经常坏,很郁闷..
 最新文章更多>> 
· IBM、惠普、Sun 三大服务器厂商..
· 用户相关文件
· 用户相关文件
· AIX系统ROOTVG镜像操作
· UNIX与ORACLE备份与恢复
· IBM红皮书上翻译的HACMP原理1
· IBM红皮书上翻译的HACMP原理2
· vi编辑器
· Install WebLogic92 on AIX
· Fragment size, 逻辑块,及存放用..
· IBM Power服务器:统一就是力量
· IBM五大系列服务器发展概述
· UNIX引领新一代数据中心未来发展
· 技术追踪:追溯POWER的前世今生
· 挥向中小企业的Power刀片
· 大型主机刀片:敢问路在何方?
· AS400之-AS_400的迅速发展及未来
· 解决部分镜像问题的方法
· RAC环境下创建物理DATAGUARD
· 关于vea界面无法正常显示的问题..
· How to verify Legato NetWorke..
· 通过HMC升级和更新P5主机微码
· 探索 AIX 6:新特性概览(下)
· 探索 AIX 6:新特性概览(中)
· 探索 AIX 6:新特性概述(上)
· AIX+HA,如何调整文件系统空间
· Maximum allocation for logica..
· 在AIX下归档大于8G的文件
· AIX 常用命令汇总
· IBM AIX V5.3 系统管理(Test 22..
· IBM AIX V5.3 系统管理(Test 22..
· AIX ,FQA第2期
 

Copyright © 2001-2018 ChinaUnix.net All Rights Reserved

感谢所有关心和支持过ChinaUnix的朋友们