Migrate System Accounts to another Server
Cloning AIX users and groups between servers
# one-liner to generate the commands to clone groups
lsgroup -c -a id ALL | grep -v ^# | awk -F: '{print "mkgroup id=" $2, $1}'
# one-liner to generate the commnads to clone users
lsuser -c -a id pgrp groups home shell gecos ALL | grep -v ^# | awk -F: '{print "useradd -m -u", $2, "-g", $3, "-G", $4, "-c \"" $7 "\" -d ", $5, $1}'
Copying AIX password hashes between servers
# grep -p root /etc/security/passwd
root:
password = 2zfymAdUyNdA.
lastupdate = 1360555127
echo 'root:2zfymAdUyNdA.' | chpasswd -ec
gen_reset_password.sh:
#!/usr/bin/ksh
for user in `lsuser -a ALL`; do
[ -n "$1" -a "$user" != "$1" ] && continue
if grep -p ^${user}: /etc/security/passwd | grep -q "password = "; then
hash=`grep -p ^${user}: /etc/security/passwd | grep "password = " | awk -F " = " '{print $2}'`
echo "echo '${user}:${hash}' | chpasswd -ec"
fi
done
# ./gen_reset_password.sh
echo 'root:2zfymAdUyNdA.' | chpasswd -ec
echo 'daemon:*' | chpasswd -ec
echo 'bin:*' | chpasswd -ec
echo 'sys:*' | chpasswd -ec
echo 'adm:*' | chpasswd -ec
echo 'uucp:*' | chpasswd -ec
echo 'guest:*' | chpasswd -ec
echo 'nobody:*' | chpasswd -ec
echo 'lpd:*' | chpasswd -ec
echo 'testusr1:MRGY5M7l56OTA' | chpasswd -ec
echo 'testusr2:skG.DjnbSmVaA' | chpasswd -ec
echo 'testusr3:EdRZo9SPb1Jig' | chpasswd -ec
echo 'testusr4:hk3qpcroid1qg' | chpasswd -ec
echo 'testusr5:1XaeSLhwCv19s' | chpasswd -ec