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 ?
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
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…
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!!
@Davoud
Thank’s for your help, why you didn’t use code tags?
For noobs it is much better.
Now i get the interowsermessage:
Internal Server Error
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the webserver log.
The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the webserver log.
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.