Disable 2FA by OCC command

I have forget to disable 2FA on WebPannel…

So, I’ve connected my laptop with the server by SSH…

When I try this command:
sudo nextcloud.occ twofactorauth:disable ********

I get this answer:
Not enough arguments (missing: “provider_id”).

For your information, i’ve installed Nextcloud by SNAP…

If you need, I have this information too:
sudo nextcloud.occ twofactorauth:disable -help

twofactorauth:disable [options] [–] <provider_id>


–output[=OUTPUT] Output format (plain, json or json_pretty, default is plain) [default: “plain”]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
–ansi Force ANSI output
–no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
–no-warnings Skip global warnings, show command output only
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Disable two-factor authentication for a user

Doussis Giorgios

Tu devrais écrire en anglais ou mettre la google trad en fin de topic. Tu aurais plus de réponses.

Ta commande est incorrecte la fin ne doit pas être le nom d’utilisateur mais le provider id. regarde la doc pour connaître la liste des providers. Ou alors connectes toi à la base de données dans la section auth tu devrais avoir le provider_id d’affiché.
Sinon tu peux désactiver l’app de double auth et tu pourras t’y reconnecter.

Merci du conseil :slight_smile:

The more strange is it:

sudo nextcloud.occ twofactorauth:state *******
Two-factor authentication is not enabled for user ********

Disabled providers:

  • backup_codes
  • gateway_signal
  • gateway_sms
  • gateway_telegram

sudo nextcloud.occ twofactorauth:enable ******** backup_codes
The provider does not support this operation.

I have always the same problem, the more strange is the the OCC command who say that my account don’t use the 2FA, … Did you think I have to make a new installation of Nextcloud ?

You could create another admin user from the occ command i hope

I can but I dont understand this synthax:
user:add [–password-from-env] [–display-name [DISPLAY-NAME]] [-g|–group [GROUP]] [–]

I didn’t understand how, but now, when I put my login, i’ve not the 2FA interruptions…
It’s very strange, here is the history of all the command I’ve use in SSH, maybe the good command is here:
! I’ve change my real username by “username”, password by “password” for more security…
Also, thank you to had try to help me :slight_smile:

This one should be the good one :
sudo nextcloud.occ twofactorauth:disable username

Don’t forget to have recovery code near you the next time.

You can both disable 2FA and create new admins from occ.

There is also a 2FA app that may interest you that allows you to generate a single use code from occ to get you logged in, as an alternative to turning 2FA off.

Thank you for your answer, but the problem was more important, i couldn’t enter a generated code, I had only “Cancel 2FA” and after that, I was redirect to the login page…

I had this answer:
sudo nextcloud.occ twofactorauth:disable username

[sudo] password for username:
Not enough arguments (missing: “provider_id”).

twofactorauth:disable [–output [OUTPUT]] [–] <provider_id>

You have to specify which 2FA provider you want to disable for the user. You can find the name by running occ config:list.

Thanks you for your answer, i will remember this command the next time I will go connect on my server :slight_smile:

For disabling 2FA by OCC , I did below steps and everything is ok and back to Normal
I use Ubuntu 20.04 LTSC with Nextcloud 22.0
1- first we need to have SSH access logion to Sever
2- find nextcloud configuration file for instance (/var/www/nextcloud/config/config.php)
3- edit config.php and try to find line -
{ ‘twofactor_enforced’ => ‘true’, } change it to { ‘twofactor_enforced’ => ‘false’, }
4- remove below lines from config.php file as well
{ ‘twofactor_enforced_groups’ =>
array (
0 => ‘admin’,
‘twofactor_enforced_excluded_groups’ =>
array (
), }
5- save it
6 - it’s Done!
7- reboot the server every thing back to normal stage and 2FA is gone!!