64

How can I disable the Two-factor Authentication module using command-line ?

3
  • 7
    just found the module with the help of grep command...this works php bin/magento module:disable Magento_TwoFactorAuth well....
    – Softec
    Commented Jul 31, 2020 at 1:45
  • please post this comment as answer
    – Amit Bera
    Commented Jul 31, 2020 at 4:12
  • Does this answer your question? Magento 2.4 - Two factor authentication
    – robsch
    Commented Sep 8, 2020 at 7:52

10 Answers 10

183

please run below command in terminal Magento root path :

bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth 
Magento_TwoFactorAuth
bin/magento cache:flush 
8
  • i would not recommend to force disable the module, rather use new module which extend the configuration so there should always be an option to control the configurations from admin panel. Commented Aug 14, 2020 at 4:02
  • @ZeeshanKhuwaja it's useful to disable this in development to avoid having to perform 2FA on your development machine when logging into admin. I wouldn't disable in production as it's a useful security feature. Commented Sep 5, 2020 at 19:50
  • 2
    Yes, this feature enabled by default is a pain for localhost installation. I would prefer to login without it and then enable this feature from the Admin panel. Commented Oct 8, 2020 at 19:52
  • 2
    For me, I needed to run "bin/magento setup:di:compile" also Commented Oct 8, 2020 at 19:56
  • 2
    This is the result of running bin/magento module:disable Magento_TwoFactorAuth The following modules have been disabled: - Magento_TwoFactorAuth Cache cleared successfully. Generated classes cleared successfully. Please run the 'setup:di:compile' command to generate classes. Info: Some modules might require static view files to be cleared. To do this, run 'module:disable' with the --clear-static-content option to clear them. So the proper answer would be to run bin/magento module:disable Magento_TwoFactorAuth bin/magento setup:di:compile Not bin/magento cache:flush
    – Martin J.
    Commented Jun 22, 2022 at 13:46
20

Mark Shust created a module for this purpose which is developer-friendly while keeping secure defaults in place; ref his comments about it

2
  • Definitely the better option to use this module than to generally disable 2FA.
    – codedge
    Commented Sep 12, 2020 at 16:55
  • 1
    Thanks @benmarks, the module works really great except the part that it does not work on the REST APIs interface. Seems the patch only works on the admin area not on all areas. Commented Nov 9, 2020 at 6:59
16

For magento 2.4.6 to disable Two Factor Authentication module

php bin/magento module:disable {Magento_AdminAdobeImsTwoFactorAuth,Magento_TwoFactorAuth}
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento indexer:reindex
php bin/magento cache:flush
2

I found a way, by adding a system configuration to Enable/Disable it. I made a module, you can download it with composer:

composer require wolfsellers/module-enabledisabletfa

Or check it at: https://github.com/wolfsellers/module-enabledisabletfa

1
  • 2
    You have copied same answer to two questions, please do some changes at content to make two answers are different
    – Amit Bera
    Commented Aug 6, 2020 at 9:08
2

It would help

bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth
1

From Magento 2.4.5 to disable Two Factor Authentication in magento 2.4

php bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth

1

Change value of Magento_TwoFactorAuth to 0 in app/etc/config.php.

0

You need first disable

bin/magento module:disable Magento_TwoFactorAuth
bin/magento module:disable Magento_TwoFactorAuth
bin/magento cache:flush 
0

If you only want to disable for a given instance, for example your development environment, you may be able to use the env.php file. If you have your "config.php" file in source control, and not your env.php file, you can then add the following to the env.php file to disable for your development environment without worrying about disabling it in the live instance:

..., 'modules' => [ 'Magento_TwoFactorAuth' => 0 ], ...

this works in 2.4.7 at least...

0

If this is for your development system, add this to your env.php in your development environment. This isn't command line per se, but the first result that pops up when searching similar issues.

    'modules' => [
        'Magento_TwoFactorAuth' => 0,
    ],

Not the answer you're looking for? Browse other questions tagged or ask your own question.