Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 6 May 1999 09:47:40 -0400
From:      Robert Beer <r-beer@onu.edu>
To:        Zheng Bokui <bokui@sin.photronics.com>, "freebsd-questions@FreeBSD.ORG" <freebsd-questions@FreeBSD.ORG>
Subject:   Re: Transfer user accounts
Message-ID:  <l03130323b35748ea2aee@[140.228.15.35]>
In-Reply-To: <37320778.8C56DB90@sin.photronics.com>

next in thread | previous in thread | raw e-mail | index | archive | help
At 4:19 PM -0400 5/6/1999, Zheng Bokui wrote:
>Hi Gurus,
>I'd like to move hundreds of user accounts from an old SunOS 4.1.3
>machine to my FreeBSD 3.1-stable PC. How can I do that? I'd like to keep
>all the old passwords so that the users don't need to key-in again.

OK, here is how I would do this.  Note that your mileage may vary.  On the=
 FreeBSD box insure that your are using DES crypt instead of MD5.  You can=
 look at the links (example from 2.2.8) in /usr/lib:
lrwxrwxrwx  1 root  bin     13 Dec 31 13:07 /usr/lib/libcrypt.a -> libdescry=
pt.a
lrwxrwxrwx  1 root  bin     18 Dec 31 13:07 /usr/lib/libcrypt.so.2.0 -> libd=
escr
ypt.so.2.0
lrwxrwxrwx  1 root  bin     15 Dec 31 13:07 /usr/lib/libcrypt_p.a -> libdesc=
rypt
_p.a

Then you need to move a copy of the Sun password file to a scratch area on=
 the FreeBSD box.  Edit the password file to remove duplicate accounts like=
 root (!) and other system accounts.  Then feed this file to the awk script=
 listed in the passwd (5) manpage:

           BEGIN { FS =3D ":"}
           { print $1 ":" $2 ":" $3 ":" $4 "::0:0:" $5 ":" $6 ":" $7 }

At this point as root you might want to create a copy of /etc/master.passwd=
 in case you experience a problem.  This is your insurance policy in case of=
 disaster.  Do have a couple of root logins going while you do this.

Now append the above editted file to /etc/master.passwd and run:

	pwd_mkdb -c /etc/master.passwd

This will check for syntax errors.  If there are no errors then run:

	pwd_mkdb -p /etc/master.passwd

This will create the hashed password files.  Now you need to create the home=
 directories of the users.  I would use a shell script something like this:

# @(#)mkuser mkuser
#
# Check the number of arguments first
#
if [ $# -lt 3 ]
then
        echo "usage: mkuser HomeDir UserName GroupName"
        exit 1
fi

#
# Create the named directory if it does not already exist
# and set the file ownership and permission
#
if [ ! -d $1 ]
then
        mkdir $1
        chgrp $3 $1
        chown $2 $1
        chmod u=3Drwx,g=3Dsx,o=3Dx $1
        mkdir $1/www
        chgrp $3 $1/www
        chown $2 $1/www
        chmod u=3Drwx,g=3Drsx,o=3Drx $1/www
fi

Invoking that like this:

for e in `tail -NNNNN /etc/passwd| cut -d: -f1`;do mkuser `grep ^$e:=
 /etc/passwd | awk -F":" '{print $6, $3, $4}'`;done

Where NNNNN is the number of lines you appended to the /etc/master.passwd fi=
le.

The above is not real efficient but you are not doing this every day.

At this point you should have users and home directories.  You may also want=
 to copy some of the dot files from /usr/share/skel into the new home=
 directories.  A script like this helps:

#!/bin/sh
# @(#)mkdot     mkdot  Copy dot files for user

## Sanity check
if [ $# -lt 1 ]; then
        echo "usage: mkdot username"
        exit 1
fi

if [  -d /home/austin/$1 ]; then

    echo "Copying Skeleton files for $1"

    ## Do .profile
    echo "Installing .profile"
    cp /usr/share/skel/dot.profile /home/$1/.profile
    chown $1 /home/$1/.profile
    chmod u=3Drw,go=3D /home/$1/.profile

    ## Do .cshrc
    echo "Installing .cshrc"
    cp /usr/share/skel/dot.cshrc /home/$1/.cshrc
    chown $1 /home/$1/.cshrc
    chmod u=3Drw,go=3D /home/$1/.cshrc

    ## Do .login
    echo "Installing .login"
    cp /usr/share/skel/dot.login /home/$1/.login
    chown $1 /home/austin/$1/.login
    chmod u=3Drw,go=3D /home/$1/.login

else

    exit 1

fi

This script assumes that that home directory is of the form /home/UserName. =
 Good luck and as I stated in the beginning your mileage may vary.


---
Bob Beer <r-beer@onu.edu>
Ohio Northern University, Academic Computer Services, Ada, OH  45810




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?l03130323b35748ea2aee>