Red Hat Training

A Red Hat training course is available for Red Hat Enterprise Linux

13.5.3. 既存 NIS データのインポートおよびエクスポート

NIS には、ユーザー、グループ、DNS およびホスト、netgroups、および自動マウントマップの情報を追加できます。これらのエントリータイプはどれでも IdM サーバーに移行できます。
移行には、ypcat を使用してデータをエクスポートし、その出力をループして、対応の ipa *-add コマンドで IdM エントリーを作成します。これは手動で行うことができますが、スクリプト化するのが最も簡単です。これらの例では、シェルスクリプトを使用します。

13.5.3.1. ユーザーエントリーのインポート

/etc/passwd ファイルには、すべての NIS ユーザー情報が含まれます。これらのエントリーは、NIS エントリーをミラーリングする UID、GID、gecos、shell、ホームディレクトリー、名前属性で IdM ユーザーアカウントを作成するのに使用できます。
たとえば、以下は nis-user.sh の例です。
#!/bin/sh
# 1 is the nis domain, 2 is the nis master 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
これは、特定の NIS ドメインに対して実行できます。
[root@nis-server ~]# kinit admin
[root@nis-server ~]# ./nis-user.sh nisdomain nis-master.example.com
注記
このスクリプトでは、ユーザーパスワードは移行されません。代わりに、一時パスワードが作成され、ユーザーの次回ログイン時に変更するようにプロンプトが表示されます。