Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm migrating users from an old server to a new one. It's only a few users, we want to migrate only the active ones and reorganize groups in the process, so I'm doing it manually. One problem remains: How can I migrate their passwords to the new server? Is there a better way than copying password hashes from /etc/shadow by hand?

share|improve this question
add comment

3 Answers 3

Since there are few enough accounts for you to migrate manually I think lifting the hashes by hand is the way to go. That's how I'd do it atleast.

share|improve this answer
add comment

Well, you wouldn't need to do it by hand. Just use lastlog to get the list of users who have logged on at least once in, for example, the past year and then grep them in /etc/shadow:

  lastlog -t 365 | gawk '{print $1}' | tail -n +2 | while read n; do \
   grep -w $n /etc/shadow; done 

You could also automate the user creation on the new server as described in my answer here.

share|improve this answer
    
TBH I'm not sure, and my first experiments aren't very successful. But I don't know any other way how to do it. –  Petr Pudlák Feb 7 '13 at 20:47
1  
Copying shadow lines does work; I did it not too long ago during a server move with lots of users. It broke a few users, but almost all still worked. –  cpast Feb 8 '13 at 0:15
add comment
up vote 2 down vote accepted

I found chpasswd tool. With -e it accepts a list of users with their encrypted passwords to set. It's just what I've been looking for.

share|improve this answer
add comment

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.