On Thu, 13 Feb 2003 13:55:04 +0200
Willie Viljoen <[EMAIL PROTECTED]> wrote:

> Does anybody know of a quick and (relatively) easy way of moving user 
> accounts between two machines?
> I need to move (roughly 200) user accounts from the old server to the
> other machine. I can't just copy master.password and the data, the
> UIDs used on the old server may conflict and clash with UIDs on the
> other server.

My two cents (hacked in 2 mins, verify before trying)

1) Copy the password file from the old machine to a temp dir in the new.
2) Trim out root,toor,daemon,nobody etc
3) csh style (change to for user in ... for sh-esque shells)

$ foreach user (`cat passwd`)
echo $user|awk -F: '{print "useradd -n " $1 " -c \"" $5 "\"" " -m " " -s" $7}'|xargs pw

This will add all those users with their name and shell. Customize if
those users don't have home dir, etc. You can do something similar for
groups. Then copy the homedirs and do a simple loop to set the proper
E.g, if each user has its own group it becomes quite trivial.

$ cd /home
$ foreach user (*)
chown -R $user:$user $user

Now the encrypted passwords. You need a copy of master.passwd and a
similar loop to the one we used before, except you should something like
sed this time. The substitution command could look like this: 

sed -i -e 's@user:\*:@user:e29rSoyJdLHFIbIt1:@' master.passwd

Building the argument string with awk should be quite trivial. Don't forget to run
pwd_mkdb after you're done!

Also, try this with temp files before, of course :)

        Miguel Mendez - [EMAIL PROTECTED]
        GPG Public Key :: http://energyhq.homeip.net/files/pubkey.txt
        EnergyHQ :: http://www.energyhq.tk
        Of course it runs NetBSD!

Attachment: msg19210/pgp00000.pgp
Description: PGP signature

Reply via email to