Locked out the admin account because 2fa was not configured

I enabled 2fa for the admin account, and now when I try to login I get an error:

Two-factor authentication is enforced but has not been configured on your account. Contact your admin for assistance

Through some searching I found the code: sudo -u www-data php /path/to/nextcloud/occ twofactorauth:disable username

which throws the error:

Not enough arguments (missing: “provider_id”).

Which is where I am stuck. I have tried various things for “provider_id” (including the username of the user, the hosting site name, www-data, www, and more I can’t remember), they all don’t exist.

Is there a way to either remove 2fa without knowing the provider ID, or otherwise is there a way to find the provider ID?


sudo -u www-data php occ twofactorauth:state username

gives you the list of enabled and disabled providers for a user.

The following worked for me in Nextcloud v16.0

  1. Go to /var/www/html/config/

  2. Edit the config.php file (vim config.php)

  3. On the line “twofactor_enforced” change the value true to false.

I hope it works for you.


I was able to get into account by manually editing config.php and changing ‘twofactor_enforced’ => ‘true’, to ‘twofactor_enforced’ => ‘false’

my file was located in /var/www/nextcloud/config/config.php
start by backing up config.php by making a copy just in case

-sudo cp /var/www/nextcloud/config/config.php /var/www/nextcloud/config/config.php.bkp
-sudo nano /var/www/nextlcloud/config/config.php
-change ‘twofactor_enforced’ => ‘true’, to ‘twofactor_enforced’ => ‘false’
-CTRL+x and y for yes to save changes and restart server

Hope it helps someone.


Thanks, it’s work for me with nextcloudpi

Thanks Xavier - it workded for me!!!