Advice on resetting admin password in Nextcloud

NethServer Version: NethServer release 7.3.1611 (Final)
Module: Nextcloud 11.0.2

Hi Team,

I’m working on my test nethserver testing my ssl certificates. I’ve seem to have lost the ability to login as the local nextcloud admin. I do know the password but for some reason it won’t work. I’m hoping I can reset the admin Nextcloud password from the command line and I’m looking to see if anyone else has done this.

I’ve been searching google for an answer and found this from ownCloud:

$ sudo -u www-data php /var/www/owncloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin

I know that Nethserver puts Nextcloud in /usr/share/nextcloud. I’ve tried submitting the above instruction pointing to my location of the occ but I’m getting errors on www-data not found.

Does anyone know if it’s possible and how I can update my local admin password for Nextcloud?

Thanks!

On CentOS, the user for the Apache web-server is apache instead of www-data.

sudo -u apache /opt/rh/rh-php56/root/usr/bin/php /usr/share/nextcloud/occ user:resetpassword admin

If there are multiple admin accounts (nextcloud’s one and also from AD/LDAP account provider) things can be confusing when trying to login.

6 Likes

As usual Excellent @dnutan!

Thanks very much for your help. Exactly what I was looking for.

1 Like

Hello, just in case helpful for somebody else:

With Nextcloud23 (and probably also with lower versions) I ran into the following issue:

[root@server1 nextcloud]# sudo -u apache /opt/rh/rh-php73/root/usr/bin/php /usr/share/nextcloud/occ user:resetpassword admin
An unhandled exception has been thrown:
OCP\HintException: [0]: Memcache \OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

I found a hint at
https://help.nextcloud.com/t/occ-wont-run-with-memcache-apcu/119724

and I could reset the admin password then…

[root@server1 nextcloud]# sudo -u apache /opt/rh/rh-php73/root/usr/bin/php --define apc.enable_cli=1 /usr/share/nextcloud/occ user:resetpassword admin
The current PHP memory limit is below the recommended value of 512MB.
Enter a new password:
Confirm the new password:
Successfully reset password for admin
[root@homeserver1 nextcloud]#

Not sure this needs to be considered somewhere else (like mentioned in the link above, php.ini ?), and maybe also helpful in nethserver nextcloud documentation?

Thanks!

Thanks for the info. Here in the forums we faced the same issue a while back.
There is a wrapper that already applies what you recommend and also a higher PHP memory limit value.
At the time of writing this, the password reset example in the wiki uses this wrapper.

occ user:resetpassword admin
2 Likes