From owner-freebsd-questions@FreeBSD.ORG Tue Apr 20 09:31:24 2004 Return-Path: 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 191CC16A4CE for ; Tue, 20 Apr 2004 09:31:24 -0700 (PDT) Received: from marshal.ul.ie (marshal.ul.ie [136.201.1.144]) by mx1.FreeBSD.org (Postfix) with ESMTP id C28DD43D49 for ; Tue, 20 Apr 2004 09:31:18 -0700 (PDT) (envelope-from brian.sheehan@ul.ie) Received: from exch-staff4.ul.ie (Not Verified[136.201.1.128]) by marshal.ul.ie with NetIQ MailMarshal (v5.5.6.6) id ; Tue, 20 Apr 2004 17:26:59 -0500 Received: from ul.ie (wearing.idc.ul.ie [136.201.107.147]) by exch-staff4.ul.ie with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2657.72) id 2T2BGTW2; Tue, 20 Apr 2004 17:24:32 +0100 Message-ID: <40854E9E.7020802@ul.ie> Date: Tue, 20 Apr 2004 17:23:58 +0100 From: Brian Sheehan User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Lowell Gilbert , freebsd-questions@freebsd.org References: <40753CC0.60104@ul.ie> <20040408143808.H30924@gwdu60.gwdg.de> <44u0zu4jmq.fsf@be-well.ilk.org> In-Reply-To: <44u0zu4jmq.fsf@be-well.ilk.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Migrating user accounts from linux to freebsd X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Apr 2004 16:31:24 -0000 Lowell Gilbert wrote: > Konrad Heuer writes: > > >>On Thu, 8 Apr 2004, Brian Sheehan wrote: >> >> >>>I've recently done a fresh installation of freebsd 4.9, and now I want >>>to migrate the user accounts from a redhat 9 machine to the new freebsd >>>machine, and hopefully keep logins and passwords unchanged. Is this >>>possible? >> >>It is possible, but you need to write a shell or perl script to combine >>the user entries in the Linux files /etc/passwd and /etc/shadow > > [...] > > There's an awk script in the passwd(5) manual for this purpose. Hi all, Thanks to Lowell & Konrad for their help. I managed migrate the accounts, without a hitch (so far so good anyway). Here is a step by step account of what i did, for future reference: 1) Created an NFS share on the linux machine, which was exported to the freebsd machine with the no_root_squash option. The entry in /etc/exports was: /home (ro,no_root_squash) 2) Copied the home directories accross with the tar command given by Konrad: tar cCf /path/to/nfs/mount - . | tar xvpCf /path/to/new/home/dirs - The following 5 steps where copied from: http://www.openbsd.org/faq/faq9.html#passwd 3) Merged /etc/passwd and /etc/shadow from the linux machine, using unshadow, part of the john the ripper suite - see http://www.openwall.com/john/ (a ports package is available) unshadow /etc/passwd /etc/shadow > linux_passwd 4) Next, I converted the results to the /etc/master.passwd format using awk: # cat linux_passwd | awk -F : '{printf("%s:%s:%s:%s::0:0:%s:%s:%s\n", \ > $1,$2,$3,$4,$5,$6,$7); }' > new_passwd 5) Now I edited new_passwd, removing any of the system account entries (root, daemon etc) and any of the user accounts that overlapped with user accounts already on the freebsd machine. 6) Merge new_passwd with /etc/master.passwd on the freebsd box # cat new_passwd >> /etc/master.passwd 7) And then generate the password database files (/etc/spwd.db and /etc/pwd.db), and the normal /etc/passwd file. # pwd_mkdb -p /etc/master.passwd 8) On both the linux box and the freebsd one, each user has its own group (of the same name of the user). For any users migrated from the linux machine to the bsd one, I also copied the corresponding entries from linux:/etc/group to freebsd:/etc/group. I hadn't seen anyone suggest doing this, but I can't see why it would be problem, and it seems to work fine. that's it! thanks again for the help, Brian