Red Hat Training
A Red Hat training course is available for RHEL 8
109.2. 将用户条目从 NIS 迁移到 IdM
NIS passwd
映射包含有关用户的信息,如名称、UID、主组、GECOS、shell 和主目录。使用此数据将 NIS 用户帐户迁移到身份管理(IdM):
先决条件
- 在 NIS 服务器中具有 root 访问权限.
- 在 IdM 中启用了 NIS。
- NIS 服务器已加入 IdM。
流程
安装
yp-tools
软件包:[root@nis-server ~]# yum install yp-tools -y
在 NIS 服务器中
创建包含以下内容的 /root/nis-users.sh
脚本:#!/bin/sh # $1 is the NIS domain, $2 is the primary NIS server ypcat -d $1 -h $2 passwd > /dev/shm/nis-map.passwd 2>&1 IFS=$'\n' for line in $(cat /dev/shm/nis-map.passwd) ; do IFS=' ' username=$(echo $line | cut -f1 -d:) # Not collecting encrypted password because we need cleartext password # to create kerberos key uid=$(echo $line | cut -f3 -d:) gid=$(echo $line | cut -f4 -d:) gecos=$(echo $line | cut -f5 -d:) homedir=$(echo $line | cut -f6 -d:) shell=$(echo $line | cut -f7 -d:) # Now create this entry echo passw0rd1 | ipa user-add $username --first=NIS --last=USER \ --password --gidnumber=$gid --uid=$uid --gecos="$gecos" --homedir=$homedir \ --shell=$shell ipa user-show $username done
以 IdM
admin
用户身份进行身份验证:[root@nis-server ~]# kinit admin
运行脚本。例如:
[root@nis-server ~]# sh /root/nis-users.sh nisdomain nis-server.example.com
重要此脚本对名字和姓氏使用硬编码的值,并将密码设置为
passw0rd1
。用户在下次登录时必须更改临时密码。