brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: occ gets a locked out Nextcloud user back in without email

Nextcloud
~/tips/tip-nextcloud-user-resetpassword

docker exec -it --user www-data nextcloud php occ user:resetpassword layla

Gets a locked out user back in without any email setup.

I love a reset mail when mail works. On a home server it often doesn’t, and the admin password is the one that gets forgotten.

Run the command with the user ID and type the new password at the prompts:

docker exec -it --user www-data nextcloud php occ user:resetpassword layla

The -it matters here, since occ has to ask you something. If you don’t know the exact user ID, occ user:list shows them. It can differ from the display name.

For a script there is an environment variable route. The variable has to exist inside the container, so pass it through with -e:

read -rs OC_PASS; export OC_PASS
docker exec -e OC_PASS --user www-data nextcloud php occ user:resetpassword --password-from-env layla
unset OC_PASS

Using read -s keeps the password out of your shell history and off the screen.

Think before you do this for someone who uses server side encryption with their own login password as key. Changing a password from outside can leave their encrypted files unreadable unless a recovery key was set up, so check the encryption section of the manual first.

Afterwards, ask the user to change it to something only they know, and to sign in again on their devices where needed.

Further reading: Nextcloud occ user commands

Going deeper: Guide: link Prowlarr to Sonarr and Radarr once, and stop typing indexers into every app

More Nextcloud tips sudo -E -u www-data php occ user:report sudo -E -u www-data php occ app:update --showonly sudo -E -u www-data php occ background-job:history -s 3 -l 10 docker exec --user www-data nextcloud php occ maintenance:mode --on docker exec -it --user www-data nextcloud php occ log:watch All Nextcloud tips (13) All topics

Link