From owner-freebsd-questions Thu Feb 13 4:23:22 2003 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CBE0437B401 for ; Thu, 13 Feb 2003 04:23:19 -0800 (PST) Received: from energyhq.homeip.net (213-97-200-73.uc.nombres.ttd.es [213.97.200.73]) by mx1.FreeBSD.org (Postfix) with ESMTP id BF71243F85 for ; Thu, 13 Feb 2003 04:23:17 -0800 (PST) (envelope-from flynn@energyhq.homeip.net) Received: from christine.energyhq.tk (christine.energyhq.tk [192.168.0.1]) by energyhq.homeip.net (Postfix) with SMTP id 9D530AF5C5; Thu, 13 Feb 2003 13:23:17 +0100 (CET) Date: Thu, 13 Feb 2003 13:23:00 +0100 From: Miguel Mendez To: Willie Viljoen Cc: freebsd-questions@freebsd.org Subject: Re: Moving user accounts from one system to another Message-Id: <20030213132300.583b8fe7.flynn@energyhq.homeip.net> In-Reply-To: <200302131355.04993.will@unfoldings.net> References: <200302131355.04993.will@unfoldings.net> X-Mailer: Sylpheed version 0.8.10 (GTK+ 1.2.10; i386--netbsdelf) X-Face: 1j}k*2E>Y\+C~E|/wehi[:dCM,{N7/uE 3o# P,{t7gA/qnovFDDuyQV.1hdT7&#d)q"xY33}{_GS>kk'S{O]nE$A`T|\4&p\&mQyexOLb8}FO List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --=.hms?H3/RZ'Q,V0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 13 Feb 2003 13:55:04 +0200 Willie Viljoen 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 end 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 uid:gid. E.g, if each user has its own group it becomes quite trivial. $ cd /home $ foreach user (*) chown -R $user:$user $user end 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 :) Cheers, -- Miguel Mendez - flynn@energyhq.homeip.net GPG Public Key :: http://energyhq.homeip.net/files/pubkey.txt EnergyHQ :: http://www.energyhq.tk Of course it runs NetBSD! --=.hms?H3/RZ'Q,V0 Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (NetBSD) iD8DBQE+S44nnLctrNyFFPERAnX9AKC9yz5JM5fy69Acrt59fyzu12+a3QCgnReg 9O/U2zPvnmiP7C5DHoWbo9o= =KaJ0 -----END PGP SIGNATURE----- --=.hms?H3/RZ'Q,V0-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message