# Transferring user from one server to another



## swapnesh (Jun 10, 2010)

I need to transfer users from one server to another.
For testing i tried to add a user into one server and copy its details from /etc/passwd, /etc/groups, /etc/master.passwd to other server created his home directory (couldnot chown) and login but this failed.

Can anyone suggest me how to do this? If this has been discussed earlier please give me the link.


```
TestServer# chown testing1:testing1 testing1/
chown: testing1: Invalid argument
```

Server Details

```
FreeBSD TestServer 6.2-RELEASE FreeBSD 6.2-RELEASE #0: Fri Jan 12 10:40:27 UTC 2007     
[email]root@dessler.cse.buffalo.edu[/email]:/usr/obj/usr/src/sys/GENERIC  i386
```


----------



## SirDice (Jun 10, 2010)

swapnesh said:
			
		

> For testing i tried to add a user into one server and copy its details from /etc/passwd, /etc/groups, /etc/master.passwd to other server created his home directory (couldnot chown) and login but this failed.


This rarely works. Mainly because the password database aren't updated. See pwd_mkdb(8). Probably the easiest is to just recreate the account(s) with pw(8).


----------



## swapnesh (Jun 10, 2010)

Thanx sirdice.
I have to migrate around 400 users, and don't want to change there password. Is there any other way i can transfer this accounts without involving users?


----------



## olav (Jun 10, 2010)

Maybe this can help? http://www.freebsd.org/doc/en/articles/ldap-auth/ldap.html


----------



## anomie (Jun 10, 2010)

Theoretically*, I would think you could:

 create all the users with a pw(8) script; be sure to preserve the UIDs/GIDs!
 copy only the needed master.passwd entries from the old host to the new host
 build the secure db from master.passwd using pwd_mkdb(8)

In this way, pw(8) takes care of all the heavy lifting for you, and with the later steps you're able to reuse existing user password hashes. 

-------

* Caveat: I don't have a FBSD crash-and-burn box to test this on at the moment. Take backups first and proceed at your own risk.


----------



## Sylgeist (Jun 10, 2010)

I've done this a few times. Use vipw to open the password database, copy and paste to the new machine, copy group entries and done! Vipw handles all the master.passwd work for you.


----------



## swapnesh (Jun 11, 2010)

vipw worked. 
Thanx a lot.


----------

