An easier way is to modify the config.php system setting
“occ config:system:set twofactor_enforced false”
this should disable 2FA if the twofactor_auth:disable command doesn’t work or doesn’t change the config.php file, just use the command below to get back into your system.
occ config:system:set twofactor_enforced false
if you are running nextcloud in a docker container, you can access the container from a terminal window OUTSIDE the container with the following
You can use occ commands:
How to find out, which provider the User use
For Native System: sudo -u www-data php /var/www/html/occ twofactor:state $username
For Docker: docker exec -u www-data nextcloud-aio-nextcloud php /var/www/html/occ twofactor:state $username
For example you get “totp” the Provider is “totp”
OCC Command to disable 2fa for a User
Native System sudo -u www-data php /var/www/html/occ twofactor:disable $username $provider_id
Docker docker exec -u www-data nextcloud-aio-nextcloud php /var/www/html/occ twofactor:disable $username $provider_id
You need to change the path of your installation, if your location is another.
If you not use Nextcloud AIO you need to change the Container Name of the Nextcloud Container.
Admin i wouldnt enforce 2FA, cause you can have problems in some cases.