Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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:)

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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 box). Log out and log back in, done!

A bit more detailed:

  1. Create the same user account on machine 2
  2. install and start opensssh-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 -avz --progress /home/user user@machine2:/home

  4. On machine 2, log out and log back in as user, done.

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
share|improve this answer
    
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? –  seanthewebber Nov 16 '12 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 '12 at 3:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.