How to transfer the passwd file

Is there a way to transfer the passwd file from an old server to a new one without losing the entries that are already in the password file?

I thought about rsyncing it to a new directory and then stripping out the duplicates and then do a

echo /path/old_passwd >> /path/to/new/passwd

I'm leery as I don't want to completely hose up a new install.
 
Back up both copies of /etc/master.passwd! Then, try something like cat old_master.passwd >> /etc/master.passwd, then remove duplicates. Next do # pwd_mkdb -p /etc/master.passwd && pwd_mkdb /etc/master.passwd.
 
To cover all bases:
passwd(5) describes four files dealing with user accounts.
FILES
/etc/passwd ASCII password file, with passwords removed
/etc/pwd.db db(3)-format password database, with passwords removed
/etc/master.passwd ASCII password file, with passwords intact
/etc/spwd.db db(3)-format password database, with passwords intact

group(5) also covers the /etc/group file.
FILES
/etc/group

If this was a minor version bump, there should be no harm in just copying the /etc/paswd, /etc/master.passwd, and /etc/group from one system to another and running pwd_mkdb /etc/master.passwd and pwd_mkdb /etc/passwd.

If this was a major bump, such as 9.X to 10.X, you would have a new user like the unbound user added and mentioned in /usr/src/UPDATING.

Personally I try to make clean installs as clean as possible and only copy what I need. Normally in this situation I think I would just manually paste the few lines in I need using vipw since that sanity checks the changes and updates the password database afterwards.
 
Back
Top