Questo contenuto non è disponibile nella lingua selezionata.
13.5. Migrating from NIS to IdM
13.5.1. Preparing Netgroup Entries in IdM
Determine what applications are using the user information in the NIS server. While some clients (like sudo
) require NIS netgroups, many clients can use Unix groups instead. If no netgroups are required, then simply create corresponding user accounts in IdM and delete the netgroups entirely. Otherwise, create the user entries in IdM and then create an IdM-managed netgroup and add those users as members. This is described in Section 13.3, “Creating Netgroups”.
Whenever a host group is created in IdM, a corresponding shadow NIS group is automatically created. These netgroups can then be managed using the ipa-host-net-manage
command.
It may be necessary to have an exact conversion, with every NIS user and host having an exact corresponding entry in IdM. In that case, each entry can be created using the original NIS names:
- Create an entry for every user referenced in a netgroup.
- Create an entry for every host referenced in a netgroup.
- Create a netgroup with the same name as the original netgroup.
- Add the users and hosts as direct members of the netgroup. Alternatively, add the users and hosts into IdM groups or other netgroups, and then add those groups as members to the netgroup.
13.5.2. Enabling the NIS Listener in Identity Management
slapi-nis
plug-in sets up a special NIS listener that receives incoming NIS requests and manages the NIS maps within the Directory Server. Identity Management uses three NIS maps:
- passwd
- group
- netgroup
slapi-nis
plug-in is not enabled by default. To enable NIS for Identity Management:
- Obtain new Kerberos credentials as an IdM admin user.
[root@ipaserver ~]# kinit admin
- Enable the NIS listener and compatibility plug-ins:
[root@ipaserver ~]# ipa-nis-manage enable [root@ipaserver ~]# ipa-compat-manage enable
- Restart the DNS and Directory Server service:
[root@server ~]# service rpcbind restart [root@server ~]# service dirsrv restart
13.5.3. Exporting and Importing the Existing NIS Data
ypcat
and then looping through that output and creating the IdM entries with the corresponding ipa *-add
commands. While this could be done manually, it is easiest to script it. These examples use a shell script.
13.5.3.1. Importing User Entries
/etc/passwd
file contains all of the NIS user information. These entries can be used to create IdM user accounts with UID, GID, gecos, shell, home directory, and name attributes that mirror the NIS entries.
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
[root@nis-server ~]# kinit admin [root@nis-server ~]# ./nis-user.sh nisdomain nis-master.example.com
Note
13.5.3.2. Importing Group Entries
/etc/group
file contains all of the NIS group information. These entries can be used to create IdM user group accounts with the GID, gecos, shell, home directory, and name attributes that mirror the NIS entries.
nis-group.sh
:
#!/bin/sh # 1 is the nis domain, 2 is the nis master 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
[root@nis-server ~]# kinit admin [root@nis-server ~]# ./nis-group.sh nisdomain nis-master.example.com
13.5.3.3. Importing Host Entries
/etc/hosts
file contains all of the NIS host information. These entries can be used to create IdM host accounts that mirror the NIS entries.
nis-hosts.sh
:
#!/bin/sh # 1 is the nis domain, 2 is the nis master server ypcat -d $1 -h $2 hosts | egrep -v "localhost|127.0.0.1" > /dev/shm/nis-map.hosts 2>&1 IFS=$'\n' for line in $(cat /dev/shm/nis-map.hosts); do IFS=' ' ipaddress=$(echo $line|awk '{print $1}') hostname=$(echo $line|awk '{print $2}') master=$(ipa env xmlrpc_uri |tr -d '[:space:]'|cut -f3 -d:|cut -f3 -d/) domain=$(ipa env domain|tr -d '[:space:]'|cut -f2 -d:) if [ $(echo $hostname|grep "\." |wc -l) -eq 0 ]; then hostname=$(echo $hostname.$domain) fi zone=$(echo $hostname|cut -f2- -d.) if [ $(ipa dnszone-show $zone 2>/dev/null | wc -l) -eq 0 ]; then ipa dnszone-add --name-server=$master --admin-email=root.$master fi ptrzone=$(echo $ipaddress|awk -F. '{print $3 "." $2 "." $1 ".in-addr.arpa."}') if [ $(ipa dnszone-show $ptrzone 2>/dev/null|wc -l) -eq 0 ]; then ipa dnszone-add $ptrzone --name-server=$master --admin-email=root.$master fi # Now create this entry ipa host-add $hostname --ip-address=$ipaddress ipa host-show $hostname done
[root@nis-server ~]# kinit admin [root@nis-server ~]# ./nis-hosts.sh nisdomain nis-master.example.com
Note
13.5.3.4. Importing Netgroup Entries
/etc/netgroup
file contains all of the NIS netgroup information. These entries can be used to create IdM netgroup accounts that mirror the NIS entries.
nis-netgroup.sh
:
#!/bin/sh # 1 is the nis domain, 2 is the nis master server ypcat -k -d $1 -h $2 netgroup > /dev/shm/nis-map.netgroup 2>&1 IFS=$'\n' for line in $(cat /dev/shm/nis-map.netgroup); do IFS=' ' netgroupname=$(echo $line|awk '{print $1}') triples=$(echo $line|sed "s/^$netgroupname //") echo "ipa netgroup-add $netgroupname --desc=NIS_NG_$netgroupname" if [ $(echo $line|grep "(,"|wc -l) -gt 0 ]; then echo "ipa netgroup-mod $netgroupname --hostcat=all" fi if [ $(echo $line|grep ",,"|wc -l) -gt 0 ]; then echo "ipa netgroup-mod $netgroupname --usercat=all" fi for triple in $triples; do triple=$(echo $triple|sed -e 's/-//g' -e 's/(//' -e 's/)//') if [ $(echo $triple|grep ",.*,"|wc -l) -gt 0 ]; then hostname=$(echo $triple|cut -f1 -d,) username=$(echo $triple|cut -f2 -d,) domain=$(echo $triple|cut -f3 -d,) hosts=""; users=""; doms=""; [ -n "$hostname" ] && hosts="--hosts=$hostname" [ -n "$username" ] && users="--users=$username" [ -n "$domain" ] && doms="--nisdomain=$domain" echo "ipa netgroup-add-member $hosts $users $doms" else netgroup=$triple echo "ipa netgroup-add $netgroup --desc=NIS_NG_$netgroup" fi done done
ipa netgroup-add-member
command always adds a host, user, and domain triple to the netgroup.
if [ $(echo $triple|grep ",.*,"|wc -l) -gt 0 ]; then hostname=$(echo $triple|cut -f1 -d,) username=$(echo $triple|cut -f2 -d,) domain=$(echo $triple|cut -f3 -d,) hosts=""; users=""; doms=""; [ -n "$hostname" ] && hosts="--hosts=$hostname" [ -n "$username" ] && users="--users=$username" [ -n "$domain" ] && doms="--nisdomain=$domain" echo "ipa netgroup-add-member $hosts $users $doms"
server,,domain
the options with the member add command are --hosts=server --users="" --nisdomain=domain
.
[root@nis-server ~]# kinit admin [root@nis-server ~]# ./nis-hosts.sh nisdomain nis-master.example.com
13.5.3.5. Importing Automount Maps
#!/bin/sh # 1 is for the automount entry in ipa ipa automountlocation-add $1 # 2 is the nis domain, 3 is the nis master 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=nisdomain.example.com+nis-map=$4,cn=NIS Server,cn=plugins,cn=config objectClass: extensibleObject nis-domain: $3 nis-map: $4 nis-base: automountmapname=$4,cn=nis,cn=automount,$basedn nis-filter: (objectclass=*) nis-key-format: %{automountKey} nis-value-format: %{automountInformation} EOF ldapadd -x -h $3 -D "cn=directory manager" -w secret -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
[root@nis-server ~]# kinit admin [root@nis-server ~]# ./nis-hosts.sh location nisdomain nis-master.example.com map
13.5.4. Setting Weak Password Encryption for NIS User Authentication to IdM
kinit
fails with password failures.
passwordStorageScheme
attribute using ldapmodify
:
[root@server ~]# ldapmodify -D "cn=directory server" -w secret -p 389 -h ipaserver.example.com dn: cn=config changetype: modify replace: passwordStorageScheme passwordStorageScheme: crypt
Note