How to disable 2FA / two factor auth

,

Hello,
i have setup a Nextcloud Test-System.
I copied my Nextcloud Production-System to the Test-System.
I wanted to disable the 2FA feature for the User Admin in Test-System:
I disabled TOTP for admin and set enforce to off.
But 2FA is still active at login, asking me to enter Backupcodes.
sudo -u www-data php /var/www/html/occ twofactorauth:state admin
Two-factor authentication is enabled for user admin
Enabled providers:

  • backup_codes
  • email
    Disabled providers:
  • admin
  • gateway_signal
  • gateway_sms
  • gateway_telegram
  • totp

Backup_codes and email is still enabled.
I cant disable them.
sudo -u www-data php /var/www/html/occ twofactorauth:disable admin email
In ProviderManager.php line 53:
The provider ‘email’ does not exist’
I assume, that because i had the provider “email” active in an older version of my Nextcloud installation, there are some remnants of it, but i can be wrong
I also can not disable the Proviser “backup_codes”.
I tried to install the twofactor_email App, but it is not compatible with me version.
Does someone have an idea?
I can see the twofactor_email App in the folder of apps.
If i delete it, it is still shown as a twofactor provider

Proxmox VE: 6.3
Nextcloud version: 20.0.3
Operating system and version: Debian 10 (LXC)
Apache or nginx version: Apache2
PHP version: 7.3

I what able to solve it. I changed the values directly in the database
Here are my steps:

  • login to mysql
  • use nextclouddb;
  • select * from oc_twofactor_providers
    in the output you can see the columns
    provider_id; uid; enabled
  • update oc_twofactor_providers set enabled = ‘0’ where provider_id = ‘email’ and uid = ‘admin’;
  • select * from oc_twofactor_providers
  • exit;
    thats it, thank you
3 Likes

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

  1. get <container_id> with → docker container ls
  2. sudo docker exec --user www-data <container_id> php occ config:system:set twofactor_enforced false
2 Likes

Hi! Can you please explain where you found the occ command to disable 2fa? Its not in their current documentation.

UPDATE: I figured it out - its a setting in the config files.

How do you have it installed ?

It is a file that “occ”

i have it in /usr/local/www/nextcloud

And the above command worked perfectly. occ config:system:set twofactor_enforced false