# migrate user accounts (password hashes) from one system to another?

**URL:** <https://forum.ansible.com/t/migrate-user-accounts-password-hashes-from-one-system-to-another/27892>\
**Category:** Ansible Project\
**Tags:** rhel, ubuntu\
**Created:** [June 28, 2018, 12:25am UTC](https://forum.ansible.com/t/migrate-user-accounts-password-hashes-from-one-system-to-another/27892 "2018-06-28T00:25:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joseph\_Filla](https://avatars.discourse-cdn.com/v4/letter/j/e9c0ed/32.png) [@Joseph\_Filla](https://forum.ansible.com/u/Joseph_Filla)\
**Post date:** [June 28, 2018, 12:25am UTC](https://forum.ansible.com/t/migrate-user-accounts-password-hashes-from-one-system-to-another/27892/1 "2018-06-28T00:25:01Z")

</div>

We’ve got some ancient ftp and sftp servers which we need to retire. Wondering how/if we could grab accounts (/etc/passwd + /etc/shadow) from old server and populate to new.

Old #1 RHEL 4.5  
Old #2 Ubuntu 12 LTS

New RHEL 7.x

I’m a newbie ansible user and wondering what some of you knowledgeable users might think.

Thanks!

Joe

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [June 28, 2018, 12:50am UTC](https://forum.ansible.com/t/migrate-user-accounts-password-hashes-from-one-system-to-another/27892/2 "2018-06-28T00:50:55Z")

</div>

the 'getent' module will get you that information, as database options  
use 'passwd' to get most user information and 'shadow' to get the  
password hashes (this last one requires root permissions)

---

<div class="post-metadata">

**Author:** ![Karl\_Auer](https://avatars.discourse-cdn.com/v4/letter/k/cc9497/32.png) [@Karl\_Auer](https://forum.ansible.com/u/Karl_Auer)\
**Post date:** [June 28, 2018, 12:54am UTC](https://forum.ansible.com/t/migrate-user-accounts-password-hashes-from-one-system-to-another/27892/3 "2018-06-28T00:54:34Z")

</div>

If the accounts do not overlap with existing account names or UIDs, you can literally just append the old files to the current ones. BTW, you need to check group names and GIDs too (/etc/groups). You could perhaps save some time by just identifying conflicts; maybe there are few enough to make this approach workable.

If there are too many conflicts you could also take those files and add something to each name and group name, to uniquify them. Then move the UIDs and GIDs into a numeric region that is not in use on the new servers. Then do the append. Passwords would remain the same, and the change to the username could be easily communicated to the users (“Your username is now the same as it was, but with ‘x’ at the end. So if your username was ‘fred’, it is now ‘fredx’”).

This would only handle users’ primary groups. You would have to also add them to suitable existing groups like “users”, “staff”, whatever.

This is all very automatable, but would take a while to do from scratch. I’d be looking for an existing product. Oh wait - that’s what you WERE doing! 🙂

Regards, K.
