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'm migrating my Ubuntu 8.10 Server to 10.04. Is there any script to migrate users /etc/passwd and groups /etc/group along with password /etc/shadow from one server to another?

share|improve this question
    
Do you mean migrate the files within the same system that is being upgraded, or to different systems? –  belacqua Mar 16 '11 at 2:38
    
To different system –  user3215 Mar 16 '11 at 4:48
add comment

1 Answer 1

These files are actually just plain-text files. You can really move them, copy and paste them, or back them up any way you wish between the systems.

In addition, you might consider some kind of versioning.
A tool like etckeeper Install etckeeper is designed for this.

apt-cache show etckeeper :

The etckeeper program is a tool to let /etc be stored in a git, mercurial, bzr or darcs repository. It hooks into APT to automatically commit changes made to /etc during package upgrades. It tracks file metadata that version control systems do not normally support, but that is important for /etc, such as the permissions of /etc/shadow. It's quite modular and configurable, while also being simple to use if you understand the basics of working with version control.

If you want to make a simple backup, just use tar.

  1. cd /etc
  2. tar cvfz myfiles.tgz shadow passwd group

To restore the files, just use tar with 'x' instead of 'c' :

  1. cd /etc
  2. tar xvfz myfiles.tgz

There should be no change in the hash algorithm between these releases. The system doesn't 'know' your passwords, -- they are calculated as matching or not matching by running the user input through a one-way digest algorithm and comparing the output to the hash in /etc/shadow. It's even conceivable that more than one input will match the stored hash, but you can't go back the other way, so as far as I know, scripting a password export is not possible.

It appears that SHA-512 has been the standard since glibc 2.7, so Ubuntu 8.10 and 10.04 should be completely compatible in this respect.

share|improve this answer
    
Yeah, I know about etckeeper. You mean to say just copy paste does the work? –  user3215 Mar 16 '11 at 4:18
1  
@user Yes, you can literally copy and paste the files. –  belacqua Mar 16 '11 at 4:19
    
Won't it differ from creating using adduser or useradd –  user3215 Mar 16 '11 at 4:53
1  
Unless I'm not understanding what you want, the files are hand-hackable. You want to copy the password hashes exactly, but there's no magic (other than consistent format of the text fields) otherwise that I know of. –  belacqua Mar 16 '11 at 5:06
1  
There should be no change in the hash algorithm between these releases -- I don't think this will be a problem. The system doesn't 'know' your passwords, so there is no way to export them. They are calculated as matching or not matching by running the user input through a one-way algorithm and comparing the output to the password in /etc/shadow. It's even conceivable that more than one input will match the stored hash, but you can't go back the other way, so as far as I know, scripting a password export is not possible. –  belacqua Mar 16 '11 at 5:30
show 4 more comments

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.