If you have lost your NextCloud password, resetting it is quite easy.
Login as the root user via SSH
Execute the command sudo -u nobody php-cli /srv/www/nextcloud/occ user:resetpassword <username>
Enter a new password as instructed
Example:
sudo -u nobody php-cli /srv/www/nextcloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin