在IBM PureApplication System上将OS身份验证与Microsoft Active Directory集成

实施IBM PureApplication System时,IBM建议与外部LDAP子系统集成。 这样可以将身份验证和组成员身份转移到IT环境中的现有公司目录中。 它适用于IBM PureApplication System管理界面的用户和组,例如系统控制台,工作负载控制台,Pure CLI和REST界面。

适当地描述了LDAP集成后,必须指出,与系统上的每个虚拟机一起部署的操作系统不会自动与该LDAP集成。 许多客户端要求操作系统与外部LDAP集成,因为它极大地简化了PureApplication System上大型VM的安全性管理。

本文介绍如何将IBM PureApplication System上的操作系统安全性与Microsoft Active Directory(许多客户端使用的LDAP实现)集成在一起。 在此详细描述如何使用虚拟机模式一部分的VM脚本包自动执行此集成。 Active Directory中要使此集成起作用所需的设置也将突出显示。

此处描述的解决方案仅适用于运行Red Hat EnterpriseLinux®的Intel®IBM PureApplication System模型(8283 / W1500和8283 / W2500)。

问题

部署虚拟系统模式时,管理员必须在部署时为一个或多个OS帐户指定密码,该密码将在Red Hat Enterprise Linux(RHEL)OS中定义。 帐户始终包含rootvirtuser ,但是取决于虚拟系统模式,也可以包含其他帐户(例如IBMDB2®的db2inst1 )。

在PureApplication System上部署虚拟系统模式将驱动一个或多个虚拟机的部署。 结果,管理大量虚拟机变得具有挑战性。 管理员需要获得这些OS帐户的密码。 管理这些帐户的生命周期可能很麻烦; 例如,您如何执行要求每三个月更改一次密码的密码策略? 其他挑战包括新人加入管理员团队,其他人离开。

考虑到这些困难,将RHEL OS与现有的Microsoft Active Directory服务集成会带来很多好处。 密码的生命周期管理将不再在PureApplication System本身上的VM范围之内。 您将需要一种用于Active Directory中存在的用户的机制来登录到已部署的VM。 需要配置RHEL操作系统,以便在用户尝试通过SSH登录时可以访问Active Directory以验证用户的凭据和组成员身份。 组成员身份可用于将对VM的访问限制为Active Directory中存在的一部分用户。

实作

此示例解决方案使用Samba对Active Directory执行身份验证。 可插拔身份验证模块 (PAM)和winbind已配置,并且实际上将RHEL主机加入了Active Directory域。 加入域需要Active Directory中的容器以及具有足够权限的绑定用户,以便在域中创建计算机对象。

一旦完成,操作系统就可以使用质询/响应对Active Directory执行身份验证。 还可以从Active Directory中获得用户的组成员身份,并且可以配置到uid和gid的一致映射。 由于RHEL主机已加入域,因此它也可以获得Kerberos票证。 这样可以在域内启用单点登录 (SSO),这是一项强大的功能。 登录到一个虚拟机后,用户可以SSH进入同一域中的另一个虚拟机,而无需重新输入密码。

由于可以删除Pure Application System上的VM,因此还需要在Active Directory中删除相应的计算机对象。 因此,这要求绑定用户具有足够的权限才能删除Active Directory中的计算机对象(图1)。

图1.解决方案概述
解决方案概述

目的是根据Active Directory中用户的组成员身份分发权限。 对于系统上的每个工作负载,您可以使用组成员身份来确定是否允许用户通过SSH登录,或者该用户是否可以执行切换用户(su)到技术用户或root用户的操作:

  • GRP_IPAS_ <工作量> _登录
    允许该组的成员使用SSH登录操作系统。
  • GRP_IPAS_ <工作量> _中间件
    允许该组的成员将用户( su )切换到OS上的一个或多个不同的技术用户; 例如,virtuser或db2inst1。
  • GRP_IPAS_ <工作量> _root
    允许该组的成员将用户(su)切换为root。

Active Directory设定

以下各节描述了Active Directory域中需要进行哪些设置。 在尝试在RHEL中配置OS安全性并加入域之前,必须先完成此操作。

  • 货柜

    为了简化此示例的Active Directory结构,请将所有相关组件放在Active Directory域根目录下的单个容器中:

    OU=IPAS,DC=dw,DC=ibm,DC=com

    在此容器中,为服务帐户,组和加入域的实际主机创建三个其他容器:

    OU=Service Accounts,OU=Users,OU=IPAS, DC=dw,DC=ibm,DC=com
    OU=Management,OU=Groups,OU=IPAS, DC=dw,DC=ibm,DC=com
    OU=Servers,OU=IPAS, DC=dw,DC=ibm,DC=com

    图2说明了您需要具备的结构。

    图2. Active Directory树设置
    Active Directory树设置
  • 服务帐号

    您需要Active Directory中的服务帐户,该服务帐户可以在加入域时创建新的计算机对象。 该帐户需要权限才能在容器OU = Servers,OU = IPAS,DC = dw,DC = ibm,DC = com中创建新的计算机对象。 离开域后,必须从容器中删除计算机对象。 因此,该帐户还需要具有从容器中删除计算机对象的权限:

    CN=IPASAD,OU=Service Accounts,OU=Users,OU=IPAS,DC=dw, DC=ibm, DC=com

  • 群组和用户

    加入域后,您将使用组成员身份来确定用户对该操作系统具有的权限。 因此,您需要创建许多可用于该目的的组。 当然,随着时间的推移,可以添加更多组:

    • GRP_IPAS_myWorkload_login
      允许该组的成员使用SSH登录操作系统。
    • GRP_IPAS_myWorkload_middleware
      允许该组的成员将用户(su)切换到OS上的一个或多个不同的技术用户; 例如,virtuser或db2inst1。
    • GRP_IPAS_myWorkload_root
      允许该组的成员将用户(su)切换为root。

    自然,也必须定义许多用户。 出于测试目的,您应该让具有不同组成员身份的用户就位。

  • 所需的RPM

    为了使与Active Directory的集成正常工作,需要以下RPM文件。 请注意,版本可能很重要。 我们发现组成员资格的行为与较旧版本的Samba / winbind二进制文件不一致。 此处列出的RPM版本已经过测试,应被视为最低版本号。

    在配置RHEL操作系统之前,需要先安装这些RPM。 根据您的虚拟系统模式使用的虚拟映像,可能已经安装了以下一些RPM:

    • libsmbclient-3.6.9-151.el6.x86_64.rpm
    • libtalloc-2.0.7-2.el6.x86_64.rpm
    • libtdb-1.2.10-1.el6.x86_64.rpm
    • openldap-clients-2.4.23-20.el6.x86_64.rpm *
    • openldap-clients-2.4.23-26.el6_3.2.x86_64.rpm *
    • openldap-clients-2.4.23-32.el6_4.1.x86_64.rpm *
    • openldap-clients-2.4.23-34.el6_5.1.x86_64.rpm *
    • samba-3.6.9-151.el6.x86_64.rpm *
    • samba-3.6.9-151.el6_4.1.x86_64.rpm *
    • samba-3.6.9-169.el6_5.x86_64.rpm *
    • samba-client-3.6.9-151.el6.x86_64.rpm
    • samba-common-3.6.9-151.el6.x86_64.rpm
    • samba-winbind-3.6.9-151.el6.x86_64.rpm
    • samba-winbind-clients-3.6.9-151.el6.x86_64.rpm

    对于此列表中标有*的软件包,要使用的确切版本取决于虚拟映像。

  • 所需数据

    这是您需要作为执行脚本的变量的数据(定义如下):

    $ADS_username
    $ADS_password
    $ADS_container_shortname
    $ADS_domain
    $ADS_workgroup
    $ADS_realm
    $ADS_login_group
    $ADS_middleware_group
    $ADS_root_group

    • 服务帐户用户名和密码:要创建(和删除)计算机对象,需要在Active Directory中较早定义的服务帐户的用户名和密码。
    • 容器名称: net ads join命令需要用于存储计算机对象的容器(OU)的名称。 OU字符串从上到下读取而没有相对专有名称(RDN),并以“ /”分隔。 在此示例中,应将容器OU = Servers,OU = IPAS,DC = dw,DC = ibm,DC = com设置为“ IPAS /服务器”。
    • 域:虚拟机的域是必需的,尤其是对于net ads join命令。 由于合格的主机名是由Pure Application System在部署时指定的,因此您将使用hostname –domain命令来获取域名,因此不需要将其公开为脚本包变量。
    • 工作组: Samba将使用要加入的工作组的名称。 在下面的代码示例中,此数据存储在$ ADS_workgroup变量中。
    • 领域:领域的名称由Samba和Kerberos配置使用。 加入Active Directory时,它还用于创建UPN(用户主体名称)。 在下面的代码示例中,此数据存储在$ ADS_realm变量中。
    • 组名:三个组的名称是设置正确权限所必需的:
      • GRP_IPAS_myWorkload_login
      • GRP_IPAS_myWorkload_middleware
      • GRP_IPAS_myWorkload_root。

配置RHEL 6 OS

以下各节描述了在RHEL 6中配置安全性以便与Active Directory集成所需的步骤。

1.识别配置文件路径

在这里,您将使用配置文件的默认文件路径。 要处理的文件是:

  • /etc/samba/smb.conf
  • /etc/security/pam_winbind.conf
  • /etc/security/access.conf
  • /etc/krb5.conf
  • / etc / sudoers。

2.启动服务

一旦安装了所有必需的RPM,第一步就是确保已启动服务messagebusoddjobdsmbwinbind

3.设置初始samba配置

用清单1中所示的代码替换文件/etc/samba/smb.conf的内容。在替换其内容之前,请保留该文件的备份副本。

清单1。
[global]
     idmap config ${HomeDirDomain} : backend=rid
     idmap config ${HomeDirDomain} : range=100000-2000000000
     winbind enum users = false
     winbind enum groups = false
     # http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#KERBEROSMETHOD
     kerberos method = secrets and keytab
     client ldap sasl wrapping = sign
     username level = 3
     server string = Samba Server Version %v
     log file = /var/log/samba/log.%m
     max log size = 50
     passdb backend = tdbsam

请注意,必须将${HomeDirDomain}字符串替换为域名缩写,可以使用以下命令来检索它:

HomeDirDomain=$(echo $ADS_domain | awk -F'.' '{print $1}' | tr '[:lower:]' '[:upper:]')

另外,请确保/ var / log / samba目录存在,否则将不会记录任何内容。

4.修改配置文件

运行authconfig实用程序来修改配置文件(清单2)。

清单2。
authconfig \
     --disablecache \
     --enablewinbind \
     --enablewinbindauth \
     --smbsecurity=ads \	
     --smbworkgroup=$ADS_workgroup \
     --smbrealm=$ADS_realm \
     --enablewinbindusedefaultdomain \
     --winbindtemplateshell=/bin/bash \
     --winbindtemplatehomedir=/home/${HomeDirDomain}/%U \
     --krb5realm=$ADS_realm \
     --enablekrb5kdcdns \
     --enablekrb5realmdns \
     --smbidmapuid=100000-2000000000 \
     --smbidmapgid=100000-2000000000 \
     --enablelocauthorize \
     --enablepamaccess \
     --enablemkhomedir \
     --disablefingerprint \
     --disablesmartcard \
     --updateall

添加了--winbindtemplatehomedir=/home/${HomeDirDomain}/%U ,以便当用户首次登录系统时,将创建主目录/ home / <domain> / <user>

运行此命令后,生成的samba配置应类似于清单3。(请记住,工作组和领域值是示例所示的示例值)。

清单3。
[global]
     #--authconfig--start-line--
     
     # Generated by authconfig on 2014/01/15 18:15:56
     # DO NOT EDIT THIS SECTION (delimited by --start-line--/--end-line--)
     # Any modification may be deleted or altered by authconfig in future
     
     workgroup = DW
     realm = DW.IBM.COM
     security = ads
     idmap uid = 100000-2000000000
     idmap gid = 100000-2000000000
     template shell = /bin/bash
     winbind use default domain = true
     winbind offline logon = false
     
     #--authconfig--end-line--
     idmap config DW : backend=rid
     idmap config DW : range=100000-2000000000
     winbind enum users = false
     winbind enum groups = false
     # http://www.samba.org/samba/docs/man/manpages-3/smb.conf.5.html#KERBEROSMETHOD
     kerberos method = secrets and keytab
     client ldap sasl wrapping = sign
     username level = 3
     server string = Samba Server Version %v
     log file = /var/log/samba/log.%m
     max log size = 50
     passdb backend = tdbsam

也将生成PAM配置,生成文件/etc/pam.d/system-auth-ac/etc/pam.d/password-auth-ac (清单4)。

清单4。
#%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_unix.so nullok try_first_pass
     auth        requisite     pam_succeed_if.so uid >= 500 quiet
     auth        sufficient    pam_winbind.so use_first_pass
     auth        required      pam_deny.so
     
     account     required      pam_access.so
     account     required      pam_unix.so broken_shadow
     account     sufficient    pam_localuser.so
     account     sufficient    pam_succeed_if.so uid < 500 quiet
     account     [default=bad success=ok user_unknown=ignore] pam_winbind.so
     account     required      pam_permit.so
     
     password    requisite     pam_cracklib.so try_first_pass retry=3 type=
     password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
     password    sufficient    pam_winbind.so use_authtok
     password    required      pam_deny.so
     
     session     optional      pam_keyinit.so revoke
     session     required      pam_limits.so
     session     optional      pam_oddjob_mkhomedir.so
     session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
     session     required      pam_unix.so

5.修改Kerberos配置

/etc/krb5.conf文件必须修改为:

  • 删除对EXAMPLE.COM的引用。
  • 添加默认的加密类型。
  • 在libdefaults部分中添加default_realm条目。
  • 将领域条目添加到领域部分。
  • 为domain_realm部分添加条目。

可以使用清单5中所示的代码完成此操作。

清单5。
# creating backup of original config file 
     cp $ADS_kerberos_config_file $ADS_kerberos_config_file.bk
     
     # remove "EXAMPLE.COM" samples entries from config file
     #cat $ADS_kerberos_config_file.bk | sed '/EXAMPLE.COM.*{.*}/d'| 
     sed '/EXAMPLE.COM.*{/,/}/d' | grep -v EXAMPLE.COM > $ADS_kerberos_config_file
     cat $ADS_kerberos_config_file.bk |grep -vi EXAMPLE |grep -v } > 
     $ADS_kerberos_config_file
     
     # configure use of arcfour-hmac-md5 and aes256-cts-hmac-sha1-96 as defaults for 
     kerberos tickets in kerberos configuration file (this is required when ADS is running 
     on Windows 2008R2 server!)
     sed -i "s/^\[libdefaults\]/\[libdefaults\]\n default_tkt_enctypes = arcfour-hmac-md5 
     aes256-cts-hmac-sha1-96\n default_tgs_enctypes = arcfour-hmac-md5 aes256-cts-hmac-sha1-96/" 
     $ADS_kerberos_config_file
     
     # add default_realm entries to libdefaults section
     sed -i "s/^\[libdefaults\]/\[libdefaults\]\n default_realm = $ADS_realm/" 
     $ADS_kerberos_config_file
     
     # add realm entries to realm section
     sed -i "s/^\[realms\]/\[realms\]\n $ADS_realm = {\n  } /" $ADS_kerberos_config_file
     
     # add entries for the domain of the actual host to kerberos configuration file to ensure 
     that they are part of the realm 
     sed -i "s/^\[domain_realm\]/\[domain_realm\]\n `hostname -d` = $ADS_realm\n .`hostname -d` 
     = $ADS_realm/" $ADS_kerberos_config_file

修改后的/etc/krb5.conf文件现在应类似于清单6。

清单6。
[logging]
     default = FILE:/var/log/krb5libs.log
     kdc = FILE:/var/log/krb5kdc.log
     admin_server = FILE:/var/log/kadmind.log
     
     [libdefaults]
     default_tkt_enctypes = arcfour-hmac-md5 aes256-cts-hmac-sha1-96
     default_tgs_enctypes = arcfour-hmac-md5 aes256-cts-hmac-sha1-96
     default_realm = DW.IBM.COM
     dns_lookup_realm = true
     dns_lookup_kdc = true
     ticket_lifetime = 24h
     renew_lifetime = 7d
     forwardable = true
     
     [realms]
     
     DW.IBM.COM = {
     }
     
     [domain_realm]
     dw.ibm.com = DW.IBM.COM
     .dw.ibm.com = DW.IBM.COM

6.加入Active Directory域

接下来,您将使计算机加入Active Directory域。 这是使用net ads join命令实现的。 更准确地说,您将运行清单7中所示的命令。

清单7。
net ads join -w $ADS_workgroup -U $ADS_username%$ADS_password 
     createupn=host/`hostname -f`@$ADS_realm createComputer=$ADS_container_shortname 
     2> /dev/null | grep -v "DNS Update"
     
     if [[ `net ads testjoin` == "Join is OK" ]]; then
     logger_info "join_ads_domain: Successfully joined domain!"
     else
     logger_error "join_ads_domain: Failed to join domain!"
     fi

在此命令中传递的变量是:

  • $ ADS_workgroup
    域中工作组的名称。
  • $ ADS_username
    Active Directory服务帐户的用户名。
  • $ ADS_password
    Active Directory服务帐户的密码。
  • $ ADS_realm
    域的领域(例如,DW.IBM.COM)。
  • $ ADS_container_shortname
    主机将被注册为计算机对象的容器的简称(例如,如果其专有名称为OU = Servers,OU = IPAS,DC = dw,DC = ibm,DC = com,则为“ IPAS / Servers”)。

请注意,此处从未使用实际Active Directory服务器的主机名。 而是,/ etc / krb5.conf中的以下两行确保通过DNS查找Active Directory域控制器:

dns_lookup_realm = true
dns_lookup_kdc = true

加入域后(即,运行net ads join命令时),Kerberos将从DNS记录中获取Active Directory域控制器。 此处的域控制器将充当Kerberos身份验证服务器以及密钥分发中心(KDC)。 知道DNS记录的类型为= SRV,并且名称的格式必须为_kerberos._tcp.<domain> 。 在这里, <domain>是主机的域(由命令hostname –d )。 当将多个域控制器用于单个域时,每个域控制器在DNS中均应有一条记录。

我们在此描述的解决方案要求域控制器的这些记录存在于DNS中。

清单8显示了如何使用DNS查找这些记录的示例。 在这种情况下,域test.dw.ibm.com总共有七个域控制器。

清单8。
nslookup -type=SRV _kerberos._tcp.test.dw.ibm.com 
     
     ;; Truncated, retrying in TCP mode.
     Server:         10.16.81.21
     Address:        10.16.81.21#53
     
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw238vdcw9re.test.dw.ibm.com.
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw244vdcw9rb.test.dw.ibm.com.
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw243vdcw9rb.test.dw.ibm.com.
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw242vdcw9re.test.dw.ibm.com.
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw376vdcw9rb.test.dw.ibm.com.
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw239vdcw9rb.test.dw.ibm.com.
     _kerberos._tcp.test.dw.ibm.com   service = 0 100 88 dw286vdcw9re.test.dw.ibm.com.

服务器成功加入域后,您可以使用清单9中所示的命令获取更多详细信息。这将向您显示在Active Directory的IPAS容器中创建的计算机对象。

清单9。
-bash-4.1# net ads status -U $ADS_username%********
     objectClass: top
     objectClass: person
     objectClass: organizationalPerson
     objectClass: user
     objectClass: computer
     cn: HOSTNAME
     distinguishedName: CN=HOSTNAME,OU=Servers,OU=IPAS,DC=dw,DC=ibm,DC=com
     instanceType: 4
     whenCreated: 20140122165553.0Z
     whenChanged: 20140122165553.0Z
     uSNCreated: 1876615
     uSNChanged: 1876622
     name: ON01P015
     objectGUID: 35ab4986-1775-4214-86ef-47efa308ba2a
     userAccountControl: 69632
     badPwdCount: 0
     codePage: 0
     countryCode: 0
     badPasswordTime: 0
     lastLogoff: 0
     lastLogon: 130348833536553755
     localPolicyFlags: 0
     pwdLastSet: 130348833532803611
     primaryGroupID: 515
     objectSid: S-1-5-21-1679220263-2264458565-1637611664-27733
     accountExpires: 9223372036854775807
     logonCount: 2
     sAMAccountName: DW01P015
     sAMAccountType: 805306369
     dNSHostName: hostname.dw.ibm.com
     userPrincipalName: host/hostname.dw.ibm.com@DW.IBM.COM
     servicePrincipalName: HOST/hostname.dw.ibm.com
     servicePrincipalName: HOST/HOSTNAME
     objectCategory: CN=Computer,CN=Schema,CN=Configuration,DC=dw,DC=ibm,DC=com
     isCriticalSystemObject: FALSE
     dSCorePropagationData: 16010101000000.0Z
     lastLogonTimestamp: 130348833536084987

假设已经正确设置了Kerberos,您还应该能够从本地密钥表文件(/etc/krb5.keytab)中看到密钥(KVNO)。 标志-e确保也显示了使用的加密类型(清单10)。

清单10。
-bash-4.1# klist -ke
     Keytab name: WRFILE:/etc/krb5.keytab
     KVNO Principal
     ---- --------------------------------------------------------------------------
     2 host/hostname.dw.ibm.com@DW.IBM.COM (des-cbc-crc)
     2 host/hostname.dw.ibm.com@DW.IBM.COM (des-cbc-md5)
     2 host/hostname.dw.ibm.com@DW.IBM.COM (arcfour-hmac)
     2 host/hostname.dw.ibm.com@DW.IBM.COM (aes128-cts-hmac-sha1-96)
     2 host/hostname.dw.ibm.com@DW.IBM.COM (aes256-cts-hmac-sha1-96)
     2 host/hostname @DW.IBM.COM (des-cbc-crc)
     2 host/hostname @DW.IBM.COM (des-cbc-md5)
     2 host/hostname @DW.IBM.COM (arcfour-hmac)
     2 host/hostname @DW.IBM.COM (aes128-cts-hmac-sha1-96)
     2 host/hostname @DW.IBM.COM (aes256-cts-hmac-sha1-96)
     2 HOSTNAME$@DW.IBM.COM (des-cbc-crc)
     2 HOSTNAME$@DW.IBM.COM (des-cbc-md5)
     2 HOSTNAME$@DW.IBM.COM (arcfour-hmac)
     2 HOSTNAME$@DW.IBM.COM (aes128-cts-hmac-sha1-96)
     2 HOSTNAME$@DW.IBM.COM (aes256-cts-hmac-sha1-96)

7.修改为Kerberos SSO生成的PAM winbind配置

接下来,您将通过编辑生成的/etc/security/pam_winbind.conf文件来修改PAM winbind配置。 设置以下参数:

  • krb5_auth = yes
  • krb5_ccache_type = FILE
  • winbind refresh tickets = yes

这些选项启用Kerberos单点登录(SSO)。 更准确地说,它们意味着PAM Winbind在与Active Directory域控制器通信时将使用Kerberos进行身份验证,并且使用一个文件来缓存检索到的票证授予票证(TGT)。 winbind refresh tickets = yes参数,与krb5_auth = yes结合使用,使winbind通过在必要时刷新TGT来使TGT保持最新。

可以使用清单11中的命令完成此操作。

清单11。
sed -i "s/.krb5_auth.*/krb5_auth = yes/g" /etc/security/pam_winbind.conf
     sed -i "s/.krb5_ccache_type.*/krb5_ccache_type = FILE/g" /etc/security/pam_winbind.conf
     echo "winbind refresh tickets = yes" >> /etc/security/pam_winbind.conf

文件/etc/security/pam_winbind.conf现在应该类似于清单12。

清单12。
#
     # pam_winbind configuration file
     #
     # /etc/security/pam_winbind.conf
     #
     
     [global]
     
     # turn on debugging
     ;debug = no
     
     # turn on extended PAM state debugging
     ;debug_state = no
     
     # request a cached login if possible
     # (needs "winbind offline logon = yes" in smb.conf)
     ;cached_login = no
     
     # authenticate using kerberos
     krb5_auth = yes
     
     # when using kerberos, request a "FILE" krb5 credential cache type
     # (leave empty to just do krb5 authentication but not have a ticket
     # afterwards)
     krb5_ccache_type = FILE
     
     # make successful authentication dependend on membership of one SID
     # (can also take a name)
     ;require_membership_of =
     
     # password expiry warning period in days
     ;warn_pwd_expire = 14
     
     # omit pam conversations
     ;silent = no
     
     # create homedirectory on the fly
     ;mkhomedir = no
     winbind refresh tickets = yes

配置RHEL 6 OS用户权限

通过RHEL 6 OS中Active Directory中用户和组的集成,您现在可以开始应用权限。 这里显示了一个相对简单的配置,但是可以根据需要设置更复杂的权限。

8.配置PAM访问

文件/etc/security/access.conf用于控制对RHEL 6 OS的访问。 使用此文件:

  1. 清除现有的配置文件。
  2. 配置所有用户对cronjobs的访问权限。
  3. 拒绝对除root用户和Active Directory中先前定义的组的成员以外的所有用户的访问。

清单13中的shell脚本显示了如何自动执行这些步骤。

清单13。
# creating backup of original config file 
     cp /etc/security/access.conf /etc/security/access.conf.bk
     
     # clear existing pam access configuration file
     >/etc/security/access.conf
     
     # configure all users access for cron jobs
     printf "+:ALL:cron\n" >> /etc/security/access.conf
     
     # configure access for root and the user(s) and groups \"${ADS_login_group}\", 
     \"${ADS_middleware_group}\" and \"${ADS_root_group}\"
     if [[ -n ${Local_users} ]];
     then
     for usr in $(echo ${Local_users}|tr "," " ")
     do
     if [[ $usr == "root" ]];
     then
     echo "root found in variable Local_users. This value is not processed. By default 
     root will be added to access.conf."
     continue
     else
     Usrs=$(printf "%s %s" "${Usrs}" "${usr}" )
     fi
     done
     fi
     
     if [[ -n ${Local_groups} ]];
     then
     for gp in $(echo ${Local_groups} |tr "," " ")
     do
     Grps=$(printf "%s %s" ${Grps} "(${gp})" )
     done
     fi
     
     printf "%sALL EXCEPT root%s %s %s %s %s:ALL\n" "-:" "${Usrs}" "${Grps}" "(${ADS_login_group})" 
     "(${ADS_middleware_group})" "(${ADS_root_group})" >> /etc/security/access.conf

现在,/ etc/security/access.conf文件应类似于清单14:

清单14。
+:ALL:cron
     -:ALL EXCEPT root GRP_IPAS_myWorkload_login GRP_IPAS_myWorkload_middleware 
     GRP_IPAS_myWorkload_root :ALL

9.配置sudo

修改/ etc / sudoers文件,以配置切换“权限”部分(清单15)中定义的用户的能力。 使用${ADS_middleware_users}变量传入本地中间件用户列表。 默认情况下,Pure Application System使用virtuser作为中间件管理员(即IBM WebSphere Application Server管理员),但是可以将更多用户添加到此列表中。

清单15。
# creating backup of original config file 
     cp /etc/sudoers /etc/sudoers.bk
     
     # clear existing sudo configuration file
     >/etc/sudoers
     
     # configure default settings for sudo configuration file
     printf 'Defaults   !visiblepw\nDefaults    always_set_home\nDefaults    env_reset\nDefaults    
     env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"\nDefaults    
     env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"\nDefaults    
     env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"\nDefaults    
     env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"\nDefaults    
     env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"\nDefaults    
     secure_path = /sbin:/bin:/usr/sbin:/usr/bin\n' > /etc/sudoers
     
     # configure root with all permissions in sudo configuration file
     printf "root            ALL=(ALL)       ALL\n" >> /etc/sudoers
     
     # configure members of group ${ADS_middleware_group} to switch to the users 
     \"${ADS_middleware_users}\" in sudo configuration file
     local sudostring=""
     IFS=","
     for username in ${ADS_middleware_users}; do
     sudostring="${sudostring} /bin/su ${username}, /bin/su - ${username}, /bin/su - ${username} 
     -c whoami,"
     done
     unset IFS
     # remove last character from sudostring as it is a ','
     sudostring=`echo ${sudostring} | rev | cut -c 2- | rev`
     printf "%%${ADS_middleware_group} ALL=NOPASSWD:${sudostring}\n" >> /etc/sudoers
     
     # configure members of group ${ADS_root_group} to switch to root in sudo configuration file
     printf "%%${ADS_root_group} ALL=NOPASSWD:ALL\n" >> /etc/sudoers

现在该文件应类似于清单16。

清单16。
Defaults   !visiblepw
     Defaults    always_set_home
     Defaults    env_reset
     Defaults    env_keep =  "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR LS_COLORS"
     Defaults    env_keep += "MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE"
     Defaults    env_keep += "LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT LC_MESSAGES"
     Defaults    env_keep += "LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE"
     Defaults    env_keep += "LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET XAUTHORITY"
     Defaults    secure_path = /sbin:/bin:/usr/sbin:/usr/bin
     root            ALL=(ALL)       ALL	
     %GRP_IPAS_myWorkload_middleware ALL=NOPASSWD:/bin/su virtuser, /bin/su - virtuser, 
     /bin/su - virtuser -c whoami
     %GRP_IPAS_myWorkload_root ALL=NOPASSWD:ALL

完成配置

现在,整个配置已完成,最后一步是在正确设置了运行级别之后,重新启动messagebusoddjobdsmbwinbind服务。

10.配置服务的运行级别

您需要为运行级别2、3、4和5启用这些服务:

  • 消息总线
  • 奇怪的
  • mb
  • 温宾德

您可以使用清单17中所示的代码来完成此操作。

清单17。
chkconfig messagebus on --level 2345
     chkconfig oddjobd on --level 2345
     chkconfig smb on --level 2345	
     chkconfig winbind on --level 2345

11.启动服务

您的最后一步是确保所有这些服务都已启动。 清单18中的脚本显示了如何以自动化方式完成此操作。

清单18。
printf "start_services: ensure services \"messagebus\", \"oddjobd\", \"smb\" 
     and \"winbind\" are all started"
     
     # Verify status of service "messagebus" and start if not running yet.
     status=`service messagebus status`
     printf $status
     if [[ $status == "messagebus is stopped" ]]; then
     printf "start_services: messagebus not running, starting..."
     printf "start_services: `service messagebus start`"
     printf "start_services: messagebus started"
     fi
     
     # Verify status of service "oddjobd" and start if not running yet.
     status=`service oddjobd status`
     printf $status
     if [[ $status == "oddjobd is stopped" ]]; then
     printf "start_services: oddjobd not running, starting..."
     printf "start_services: `service oddjobd start`"
     printf "start_services: oddjobd started"
     fi
     
     # Verify status of service "smb" and start if not running yet.
     local status=`service smb status`
     printf $status
     if [[ $status == "smbd is stopped" ]]; then
     printf "start_services: smb not running, starting..."
     printf "start_services: `service smb start`"
     printf "start_services: smb started"
     fi
     
     #Verify status of service "winbindd" and start if not running yet.
     status=`service winbind status`
     printf $status
     if [[ $status == "winbindd is stopped" ]] || [[ $status == "winbindd dead but 
     pid file exists" ]]; then
     printf "start_services: winbind not running, starting..."
     printf "start_services: `service winbind start`"
     printf "start_services: winbind started"
     fi
     
     printf "start_services: all services started"
     return 0

使用Active Directory实施RHEL 6 OS身份验证

默认情况下,RHEL 6 OS实施其本地密码策略。 现在,虚拟机正在使用Active Directory进行身份验证,您可以禁用RHEL本地策略并使用Active Directory密码策略。

要禁用RHEL 6本地密码策略,请将清单19所示的更改更改为/ etc / security / system-auth-ac

清单19。
#%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_unix.so nullok try_first_pass
     auth        requisite     pam_succeed_if.so uid >= 500 quiet
     auth        sufficient    pam_winbind.so use_first_pass
     auth        required      pam_deny.so
     
     account     required      pam_access.so
     account     required      pam_unix.so broken_shadow
     account     sufficient    pam_localuser.so
     account     sufficient    pam_succeed_if.so uid < 500 quiet
     account     [default=bad success=ok user_unknown=ignore] pam_winbind.so
     account     required      pam_permit.so
     
     # password    requisite     pam_cracklib.so try_first_pass retry=3 type=
     password    sufficient    pam_unix.so sha512 shadow nullok try_first_pass use_authtok
     # password    sufficient    pam_winbind.so use_authtok
     password    sufficient    pam_winbind.so
     password    required      pam_deny.so
     
     session     optional      pam_keyinit.so revoke
     session     required      pam_limits.so
     session     optional      pam_oddjob_mkhomedir.so
     session     [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
     session     required      pam_unix.so

清单20显示了一个Active Directory实施其密码策略的示例。

清单20。
-bash-4.1$ passwd
     Changing password for user dwuser01.
     Changing password for dwuser01
     (current) NT password:
     New password:
     Retype new password:
     Password does not meet complexity requirements
     Your password must be at least 8 characters; cannot repeat any of your previous 
     10 passwords; must contain capitals, numerals or punctuation; and cannot contain your 
     account or full name; Please type a different password. Type a password which meets these 
     requirements in both text boxes.
     passwd: Authentication token manipulation error

从Active Directory移除虚拟机

删除虚拟机时(通常是删除虚拟机所属的虚拟系统实例的结果),与该虚拟机关联的主机应离开Active Directory域。 这还将删除Active Directory中的相应计算机对象。 可以发出以下命令离开域:

net ads leave -U $ADS_username%$ADS_password

变量$ ADS_username$ ADS_password是Active Directory服务帐户的用户名和密码。

放在一起

既然您已经了解了如何自动执行Active Directory集成的配置,那么就可以构建脚本包了。 然后,这些可以包含在虚拟系统模式中,稍后您将看到。

脚本包

出于本文的目的,已包括两个脚本包作为示例:

  • add_ad_os_authentication必须在创建VM时运行,并且基本上将VM配置并集成到Active Directory域。
  • remove_ad_os_authentication必须在删除VM时运行,并将此VM从Active Directory域中删除。

脚本包:添加AD OS身份验证

此脚本包执行本文所述的步骤1至11,以将RHEL 6身份验证与Active Directory集成:

  1. 识别配置文件路径
  2. 启动服务
  3. 设置初始samba配置
  4. 修改配置文件
  5. 修改Kerberos配置
  6. 加入Active Directory域
  7. 修改为Kerberos SSO生成的PAM winbind配置
  8. 配置PAM访问
  9. 配置Sudo
  10. 配置服务的运行级别
  11. 启动服务

在此脚本包中,RPM的安装是使用脚本包zip文件中包含的本地文件完成的。 更好的解决方案是改用PureApplication System提供的RedHat OS更新共享服务。

由于此示例脚本包使用本地RPM文件,因此引入了一个名为OS_IMAGE的附加参数,以确保将安装该映像的正确RPM。 它指的是从目录中获取的虚拟映像,虚拟目录模式的每个部分都使用该目录。 该虚拟映像类型可以是例如“ Core OS 2.0.0.4”,“ DB2 Enterprise 9.7.0.8”或“ WAS 8.5.5.1。”。

名称:添加AD OS身份验证
execmode: 0(在创建虚拟系统时)
描述:安装RPM并配置Active Directory OS身份验证
羡慕地: TRUE
savevars: 0

表1.用于添加AD OS身份验证的参数
参数 类型 需要 示例值 描述
OS_IMAGE (默认) 真正 有效值为:
BPM 8.0.1.0
BPM 8.5.0.1
核心作业系统2.0.0.1
核心作业系统2.0.0.3
核心作业系统2.0.0.4
核心作业系统2.1.0.0
IIS 9.1.0.0 CN
IIS 9.1.0.0 ZH
WAS 8.0.0.4
WAS 8.0.0.5
WAS 8.0.0.7
是8.5.0.0
表示用于部署VM的虚拟系统映像。 此列表用于安装正确的RPM。 该列表需要修改。
ADS_用户名 (默认) 真正 ipasad 与Active Directory绑定的用户名,并具有添加计算机对象的权限
ADS_password 密码 真正 ******** 以上用户名的密码
ADS_container_shortname (默认) 真正 IPAS /服务器 net ads join命令需要用于存储计算机对象的容器(OU)的名称。 OU字符串从上到下读取而没有相对专有名称(RDN),并以“ /”分隔。
ADS_workgroup (默认) 真正 DW 域中工作组的名称
ADS_realm (默认) 真正 德国软件公司 领域的名称由Samba和Kerberos配置使用。
ADS_login_group (默认) 真正 GRP_IPAS_ <工作量> _登录 允许Active Directory中该组的成员使用SSH登录到操作系统
ADS_middleware_group (默认) 真正 GRP_IPAS_ <工作量> _中间件 根据ADS_middleware_users的指定,允许Active Directory中此组的成员将用户(su)切换到操作系统上的一个或多个不同的技术用户。
ADS_root_group (默认) 真正 GRP_IPAS_ <工作量> _root 允许Active Directory中该组的成员将用户(su)切换为“ root”。
ADS_middleware_users (默认) 真正 virtuser,db2inst1 逗号分隔的列表,其中包含Active Directory中定义的OS上中间件的技术用户(例如virtuser,db2inst1等)。

脚本包:删除AD OS身份验证

该脚本包的目的是确保主机在删除虚拟机时离开域。 因此,此脚本包被配置为在删除虚拟系统时运行。 由于此脚本包将在删除时执行,因此请记住,删除虚拟系统实例时必须运行虚拟机。 如果虚拟机已停止,则不会执行脚本包。

名称:删除AD OS身份验证
execmode: 1(删除虚拟系统时)
说明:从Active Directory中删除虚拟机
羡慕地: TRUE
savevars: 0

表2.删除AD OS认证的参数
参数 类型 需要 示例值 描述
Remove_AD_ADS_container (默认) 真正 OU = IPAS,DC = dw,DC = ibm,DC = com Active Directory中存储计算机对象的容器的可分辨名称。
Remove_AD_ADS_user (默认) 真正 ipasad 与Active Directory绑定的用户名,并有权删除计算机对象
Remove_AD_ADS_password 密码 真正 ******** 以上用户名的密码

虚拟系统模式

使用以上两个脚本包,您现在可以构建一个简单的虚拟系统模式,该模式将在部署时自动加入Active Directory域。 您只需将两个脚本包添加到要在其上进行Active Directory身份验证的每个VM(图3)。 请谨慎选择OS_IMAGE参数的正确值,具体取决于要在其上添加脚本包的VM。

图3.示例虚拟系统模式(Pure Application System v2.0固件)
虚拟系统模式样本(Pure Application System v2.0固件)

使用Active Directory凭据登录

清单21显示了使用Active Directory凭据登录的用户示例,其中显示了组成员身份。 该组成员资格使用户可以执行sudo su – virtusersudo –i (root)

清单21。
login as: dwuser01
     dwuser01@pas01-grp063.dw.ibm.com's password:
     -bash-4.1$ id
     uid=138373(dwuser01) gid=100513(domain users) groups=100513(domain users),
     138530(GRP_IPAS_myWorkload_login),138531(GRP_IPAS_myWorkload_middleware),
     138532(GRP_IPAS_myWorkload_root)
     -bash-4.1$ sudo -i
     -bash-4.1$ id
     uid=0(root) gid=0(root) groups=0(root),1(bin),2(daemon),3(sys),4(adm),6(disk),10(wheel)
     -bash-4.1$ logout
     -bash-4.1$ sudo su - virtuser
     [virtuser@pas01-grp063 ~]$ id
     uid=1000(virtuser gid=501(virtuser) groups=501(virtuser)
     [virtuser@pas01-grp063 ~]$

使用SSO登录

清单22显示了一个用户使用Single Sign-On从一个VM(pas01-grp063.dw.ibm.com)登录到另一个VM(pas01-grp064.dw.ibm.com)的示例。 由于两者都是同一个Active Directory域的一部分,因此不需要密码,因为Kerberos通过单一登录来处理此密码。

清单22。
login as: dwuser01
     dwuser01@pas01-grp063.dw.ibm.com's password:
     -bash-4.1$ id
     uid=138373(dwuser01) gid=100513(domain users) groups=100513(domain users),
     138530(GRP_IPAS_myWorkload_login),138531(GRP_IPAS_myWorkload_middleware),
     138532(GRP_IPAS_myWorkload_root)
     -bash-4.1$ ssh pas01-grp064.dw.ibm.com
     -bash-4.1$ id
     uid=138373(dwuser01) gid=100513(domain users) groups=100513(domain users),
     138530(GRP_IPAS_myWorkload_login),138531(GRP_IPAS_myWorkload_middleware),
     138532(GRP_IPAS_myWorkload_root)
     -bash-4.1$

虚拟系统模式(经典)

该解决方案与经典虚拟系统模式完全相同,并且可以使用相同的脚本包。 您必须将两个脚本包添加到要进行Active Directory身份验证的每个部分(图4)。 小心选择OS_IMAGE参数的正确值,具体取决于要添加脚本包的部分。

图4.示例虚拟系统模式(经典)
虚拟系统模式样本(经典)

结论

将在IBM PureApplication System上运行的虚拟机与公司Active Directory集成在一起非常有用,因为它可以在整个IT基础架构中带来一致性。 可以在Active Directory中集中管理用户和组,并可以利用现有的密码策略,从而大大减少了在PureApplication System上维护大量虚拟机的工作。 本文介绍了与运行RedHat OS的VM集成所需的步骤,并提供了一组示例脚本包,可用于加速实施。


翻译自: https://www.ibm.com/developerworks/websphere/techjournal/1410_vanrun/1410_vanrun.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值