Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Migrating etc password file from Red Hat 9 to Enterprise

Posted on 2005-04-13
11
Medium Priority
?
310 Views
Last Modified: 2013-12-06
We need to know if there is a way or tool to migrate the etc password file from 9 to enterprise. This is an extremely URGENT issue, so if you could respond quickly it would be greatly appreciated. Please let me know if you need more information.. As I am a novice to Linux.. Thanks in advance!!

Larissa
0
Comment
Question by:onsite_tech
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 23

Expert Comment

by:Mysidia
ID: 13778190
I don't have the specifics for Enterprise's peculiarities, but the same kind of password file
ought to work on both systems, unless one has customized it.

But if you want to Migrate  /etc/passwd over
you will also need to migrate over   /etc/shadow

And possibly
  /etc/group
and
   /etc/gshadow

To move users' group ids over as well

/etc/passwd   is the file that should be publicly readable (by all users of the system)
and just contains the user database  for use by the basic commands

/etc/shadow     is the file that contains actual matching passwords for all the users,
and should be readable only by root.

The format for the files is fairly typical, though the encryption methods/settings may differ
between releases or systems

Try  /etc/libuser.conf    for settings details
if both systems have it, and/or they both have the same cryptstyle,
then the password configuration should be basically interchangeable,
I think.. so long as all the password files make it over in the migration
0
 
LVL 48

Expert Comment

by:Tintin
ID: 13778563
If you haven't changed any defaults, you can simply copy across

/etc/passwd
/etc/shadow
/etc/group

0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13783473
Hi,

   Before you copy over those 3 files which other experts suggested, please make a copy of them.
cp /etc/passwd /etc/passwd.original
cp /etc/shadow /etc/shadow.original
cp /etc/group /etc/group.original

   After copying over those files, compare
/etc/passwd amd /etc/passwd.orig
and check for the system account with user account, make sure the old user account in /etc/passwd doesn't have the
same UID as the new system/service account in /etc/passwd.orig.
It yes, then change the UID of system account or user account.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Author Comment

by:onsite_tech
ID: 13816433
we ended up finding a redhat "unoffical" migration script that snagged all of the users and thier home dirs and threw them into a tar file.  that worked great (if a bit slow) and we migrated it over to the new server, but now we have a problem cause the tar file is 5 gigabytes and every time we try to do anything with it (view the files in it or extract it) it just kinda sits there and doesn't really do anything (the process load on the box doesn't go up, it just sits there).

anyone have any ideas on how to handle files this big and untarring them?
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13819393
Could you post the URL of the migration script, which you downloaded?
You might need to modify the script for the tar to archive into separate small tar.gz files.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 13820925
What happens when you do:

strace tar ztvf tarfile.tgz

0
 
LVL 1

Author Comment

by:onsite_tech
ID: 13828937
i'm having a hard time finding the actual page on redhat's site but here is the script itself:

#!/bin/bash
#
# * by Chris Kloiber <ckloiber@redhat.com>
#
# Quick and dirty hack to migrate user and group data from a sick
# machine to a new machine. This script is provided "AS-IS", and is
# licenced to you under the GPL, which as always can be downloaded
# from http://www.gnu.org/copyleft/gpl.html
#
# Although I work for Red Hat, Inc. this script is not a product
# of Red Hat, Inc. It has not been through QA other than my own
# testing. It might eat your data, but it didn't eat mine. YMMV.

CUSTOMIZED=yes
if [ $CUSTOMIZED = 'no' ]; then
        echo "Take a moment to edit this script to customize it";
        echo "for your particular environment. Edit this script";
        echo "and change the CUSTOMIZED variable to 'yes' to";
        echo "bypass this message.";
        exit 0;
fi

# This backup uses 'tar', you get to choose the compression.
# You can specify a /location/filename for the tar.

# Leave off the file extention. It will be added based on COMPRESSION
# BACKUP_PATH=/mnt/dist/
# BACKUP_FILE=$(hostname)-$(date -I)
BACKUP_PATH=~/
BACKUP_FILE=$(hostname)-$(date -I)

# If you set TAPE_DEVICE, BACKUP_PATH and BACKUP_FILE are ignored.
# If you don't have a tape drive, leave this blank. (tapes not tested)
TAPE_DEVICE=

# The choices for compression are: bzip2, gzip or none
COMPRESSION=none

# Be clean (or not, this script is for dying machines afterall)
CLEANUP=yes

# Paths to home and mail, relative to / (but don't include the /)
HOMEDIR="home"
MAILDIR="var/spool/mail"

# Other variables that should not need changing often, if at all.
PASSWD="/etc/passwd"
GROUP="/etc/group"
SHADOW="/etc/shadow"
USERS="/tmp/userlist"
BLIST="/tmp/backup.list"

# Here we parse the group, passwd, and shadow files.
# We do *not* write to the original files, but instead create *.sav files
# (this part took me several hours to figure out...)

awk -F ":" -- '{if ($3>='499' && $3!='65534') print}' $GROUP > $GROUP.sav
awk -F ":" -- '{if ($3>='499' && $3!='65534') print}' $PASSWD > $PASSWD.sav

for i in $(awk -F ":" -- '{print $1}' $PASSWD.sav) ; do
        awk -v user=$i -F ":" -- '{if ($1==user) print}' $SHADOW >> $SHADOW.sav;
        echo $i >> $USERS
done

# Now we have tossed out the system accounts, and have pure user data.
# It's time to grab the home and mail directories. I will build a list
# of directories to back up, then use it to make a tarfile.

echo $GROUP.sav > $BLIST
echo $PASSWD.sav >> $BLIST
echo $SHADOW.sav >> $BLIST

for i in $(cat $USERS) ; do
        echo $HOMEDIR/$i >> $BLIST ;
        echo $MAILDIR/$i >> $BLIST ;
done

# Actually make the archive

cd /
if [ $TAPE_DEVICE ]; then
        if [ $COMPRESSION = 'bzip2' ]; then
                tar -T $BLIST -jcvf $TAPE_DEVICE ;
        elif [ $COMPRESSION = 'gzip' ]; then
                tar -T $BLIST -zcvf $TAPE_DEVICE ;
        else
                tar -T $BLIST -cvf $TAPE_DEVICE ;
        fi
else
        if [ $COMPRESSION = 'bzip2' ]; then
                tar -T $BLIST -jcvf $BACKUP_PATH/$BACKUP_FILE.tar.bz2 ;
        elif [ $COMPRESSION = 'gzip' ]; then
                tar -T $BLIST -zcvf $BACKUP_PATH/$BACKUP_FILE.tar.gz ;
        else
                tar -T $BLIST -cvf $BACKUP_PATH/$BACKUP_FILE.tar ;
        fi ;
fi

# cleanup temporary files
if [ $CLEANUP = 'yes' ]; then
        rm -f $GROUP.sav $PASSWD.sav $SHADOW.sav $USERS $BLIST
fi

echo ""
echo "You are done on this end. (Yay!)"
echo ""
echo "When you have extracted the archive on the target machine there is"
echo "still some work to be done. You will need to add the user information"
echo "found in the /etc/*.sav files to the end of the new system's"
echo "/etc/group, /etc/passwd and /etc/shadow files. You must do this while"
echo "making sure there is no overlap of uid or gid numbers. This will"
echo "usually happen for uid=500 if you created a user account on the new"
echo "machine during install. Just be aware of it, it's not hard to fix."
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13829119
> for i in $(cat $USERS) ; do
>         echo $HOMEDIR/$i >> $BLIST ;
>         echo $MAILDIR/$i >> $BLIST ;
> done
Comment out this portion and move over the home direcotry and mail folder manually.

In this script, it assumes all the home directories are under /home
and all the unread mails are under /var/spool/mail
0
 
LVL 1

Author Comment

by:onsite_tech
ID: 14068877
I figured out why the tar file wasn't working correctly.  the partitions on this box were loaded weird and the disk i was extracting it to didn't have enough space.  it works fine now though.  pretty cool script.
0
 

Accepted Solution

by:
OzzMod earned 0 total points
ID: 14099309
Closed, 500 points refunded.
OzzMod
Community Support Moderator (Graveyard shift)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Suggested Courses
Course of the Month21 days, 1 hour left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question