67

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.... Commented Jul 31, 2020 at 1:45
  • please post this comment as answer Commented Jul 31, 2020 at 4:12
  • Does this answer your question? Magento 2.4 - Two factor authentication Commented Sep 8, 2020 at 7:52

10 Answers 10

195

please run the below command in the 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 Commented Jun 22, 2022 at 13:46
21

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. 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
18

For magento 2.4.6 and 2.4.7 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 
1
  • 1
    This worked for me on 2.4.7. thanks Commented Oct 7, 2024 at 5:07
3

It would help

bin/magento module:disable Magento_AdminAdobeImsTwoFactorAuth Magento_TwoFactorAuth 
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 Commented Aug 6, 2020 at 9:08
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.

1

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, ], 
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...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.