Red Hat Training

A Red Hat training course is available for RHEL 8

112.3. 将用户组从 NIS 迁移到 IdM

NIS 映射包含有关组的信息,如组名称、GID 或组成员。使用此数据将 NIS 组迁移到身份管理(IdM):

先决条件

流程

  1. 安装 yp-tools 软件包:

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

    #!/bin/sh
    # $1 is the NIS domain, $2 is the primary NIS server
    ypcat -d $1 -h $2 group > /dev/shm/nis-map.group 2>&1
    
    IFS=$'\n'
    for line in $(cat /dev/shm/nis-map.group); do
    	IFS=' '
    	groupname=$(echo $line | cut -f1 -d:)
    	# Not collecting encrypted password because we need cleartext password
    	# to create kerberos key
    	gid=$(echo $line | cut -f3 -d:)
    	members=$(echo $line | cut -f4 -d:)
    
    	# Now create this entry
    	ipa group-add $groupname --desc=NIS_GROUP_$groupname --gid=$gid
    	if [ -n "$members" ]; then
    		ipa group-add-member $groupname --users={$members}
    	fi
    	ipa group-show $groupname
    done
  3. 以 IdM admin 用户身份进行身份验证:

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

    [root@nis-server ~]# sh /root/nis-groups.sh nisdomain nis-server.example.com