3

I would like to make a shell script that enables me to literally copy one user account on one Ubuntu box to another machine running Ubuntu. The idea is to be able to log into that user account on the new machine JUST LIKE I did on the old one. Any ideas? Howto's? Other things I need to look out for that might make the system blow up? Thanks:)

1 Answer 1

2

Easiest way: use rsync to copy your ~ folder over SSH to another machine (suppose that the same user account with same password exists on that target host). Log in as that user (it is always safer to restart display manager).

A bit more detailed:

  1. Create the same user account on machine 2

  2. install and start openssh-server on both boxes and start them

  3. Use rsync to copy the entire ~ over SSH to machine 2, for example, you are pushing ~ from machine 1 to machine 2 (of course it can be done the other way around - pull)

    rsync -avhz --progress --stats /home/user user@machine2:/home
    
  4. On machine 2, make sure the owner / group is correct, restart display manager (or the host) and login as that user

BTW: if you want to have exactly the same packages installed on both machines (need to be on the same arch), use

sudo dpkg --get-selections > pkg.list

scp or rsync the file to machine 2 and do the following

sudo dpkg --set-selections < pkg.list
sudo apt-get dselect-upgrade
2
  • Thank you for the details! I got a little bit confused on one small detail though. Do you create the user account on machine 2 first THEN rsync all the files to it, or literally copy machine1's ~ directory to the /home directory of machine2?
    – user101351
    Nov 16, 2012 at 1:40
  • Create user account on both machines first, otherwise you'll have to take more files in /etc into account: passwd, shadow, group, gshadown and probably more.
    – Terry Wang
    Nov 16, 2012 at 3:45

You must log in to answer this question.