Reset a Lost Nextcloud Admin Password with OCC
Administrators can recover access to a Nextcloud account by using the OCC command in the server shell, even if web interface access is unavailable.
Nextcloud provides a command-line utility, OCC, that allows administrators to reset a lost password directly from the server shell, bypassing the web interface. This method is useful when access to the web interface is lost, but shell access remains available, and it functions for both administrator and regular user accounts.
The OCC command requires execution as the web server user, typically www-data on Debian or Ubuntu systems, and within the Nextcloud installation directory. The command prompts for a new password without storing it in the shell history for security reasons, and it’s important to use the PHP CLI version configured for the web server.
When using external identity providers like LDAP or SAML, the OCC command may not affect the actual sign-in password, which is managed by the provider. Users should consult the provider’s documentation for password resets or verify backend support before attempting a reset with OCC.