Red Hat Training

A Red Hat training course is available for RHEL 8

112.6. 将自动挂载映射从 NIS 迁移到 IdM

自动挂载映射是一系列嵌套的条目,它们定义位置(父条目)、关联的键和映射。将 NIS 自动挂载映射到身份管理(IdM):

先决条件

流程

  1. 安装 yp-tools 软件包:

    [root@nis-server ~]# yum install yp-tools -y
  2. 使用 NIS 服务器的以下内容创建 /root/nis-automounts.sh 脚本:

    #!/bin/sh
    # $1 is for the automount entry in ipa
    
    ipa automountlocation-add $1
    
    # $2 is the NIS domain, $3 is the primary NIS server, $4 is the map name
    
    ypcat -k -d $2 -h $3 $4 > /dev/shm/nis-map.$4 2>&1
    
    ipa automountmap-add $1 $4
    
    basedn=$(ipa env basedn | tr -d '[:space:]' | cut -f2 -d:)
    cat > /tmp/amap.ldif <<EOF
    dn: nis-domain=$2+nis-map=$4,cn=NIS Server,cn=plugins,cn=config
    objectClass: extensibleObject
    nis-domain: $2
    nis-map: $4
    nis-base: automountmapname=$4,cn=$1,cn=automount,$basedn
    nis-filter: (objectclass=\*)
    nis-key-format: %{automountKey}
    nis-value-format: %{automountInformation}
    EOF
    ldapadd -x -h $3 -D "cn=Directory Manager" -W -f /tmp/amap.ldif
    
    IFS=$'\n'
    for line in $(cat /dev/shm/nis-map.$4); do
    	IFS=" "
    	key=$(echo "$line" | awk '{print $1}')
    	info=$(echo "$line" | sed -e "s^$key[ \t]*")
    	ipa automountkey-add nis $4 --key="$key" --info="$info"
    done
    注意

    脚本导出 NIS 自动挂载信息,为自动挂载位置和相关映射生成 LDAP 数据交换格式(LDIF),并将 LDIF 文件导入到 IdM 目录服务器。

  3. 以 IdM admin 用户身份进行身份验证:

    [root@nis-server ~]# kinit admin
  4. 运行脚本。例如:

    [root@nis-server ~]# sh /root/nis-automounts.sh location nisdomain
         nis-server.example.com map_name