Migration from pw_auth to LDAP keeping users and data

I’m migrating my user backend from the unix authentication app pw_auth to LDAP and want to share my experiences because I encountered some problem. While searching for solutions I only discovered unanswered threads like:

Many thanks to @Uli_He again for the great tutorial (Migration to LDAP keeping users and data)

  1. Setup your LDAP server and configure the LDAP nextcloud settings like in ulis thread.
  2. Since the user via pw_auth aren’t stored in the database skip this part.
  3. Backup your /etc/passwd (e.g. cp /etc/passwd /etc/passwd.backup)
  4. Delete all user rows in your passwd that are now available via LDAP. (Note: Disabling the userid via the settings did not work. The user disappears from the user web overview but is still reachable on occ user:info [username])
  5. Now do the 7th step from ulis thread in the nextcloud LDAP settings (Delete LDAP user relations, Delete LDAP group relations). Note: The attribute for the internal username must be the same as for the unix user in the passwd file.
  6. Now you can login with your LDAP credentials!

(After loging successfull you might recover your passwd file from your backup, if need the authentication there. Make sure to disable the pw_auth plugin or disable now the user ids in the nextcloud settings)

I hope that I could help someone! :slight_smile:

As always make sure to have a fullbackup before migrating your users.

Note: If you are using server-side encryption make sure to use the same passwords in LDAP or (let them) recover the password after migrating.