Nexcess Logo

Magento 2 Admin Login: Disable 2FA

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
July 14, 2022


Admin users can disable the Two-Factor Authentication (2FA) by using the command line methods from the Magento 2 root directory documented in this article.

 

Magento 2 Admin Login & Two-Factor Authentication (2FA)

What is Two-Factor Authentication (2FA)?

Two-Factor Authentication (2FA) is one category of Multi-Factor Authentication (MFA) that strengthens access security requirements by needing two authentication factors/methods to verify your identity.

Why Would You Want to Disable Two-Factor Authentication (2FA) in Magento 2.4 & Greater Versions?

Although earlier versions of Magento offered options to not install or to disable Two-Factor Authentication (2FA), Magento 2.4 and greater versions enable 2FA by default on every installation. The Magento admin user must disable 2FA using the command line. 

While it is never recommended to disable 2FA in Magento 2.4 and greater versions, given its strength of security, there are a few scenarios in which you may want to disable it: 

1. To enable the admin user to log into the Magento 2 Admin Panel Dashboard for the first time due to 2FA warning message. 

2. When 2FA is not needed in a staging environment. 

3. When 2FA is not needed in a testing environment. 

4. When 2FA is not needed in a development environment.

Magento 2.4 & Two-Factor Authentication (2FA)

By default, Magento will enable Two-Factor Authentication (2FA) after Magento version 2.4. So, before logging into the Magento Admin Panel Dashboard, the admin users will need to configure their 2FA either through the user interface or a web API. The 2FA provides an additional layer of security to the Magento 2 Admin Panel, making it harder for suspicious users to log in to the Magento 2 Admin Panel Dashboard without authorization. It also helps decrease the chance of questionable access to the Magneto 2 Admin Panel Dashboard. So, we do not recommend that you disable 2FA authentication in your Magento 2 Admin Panel Dashboard for security reasons. If you still do not wish to use 2FA, you can disable 2FA for the development, testing, or staging, environment or store.

Once you install Magento 2 for your domain, you will receive the following warning message while trying to access the Magento Admin Panel Dashboard for the first time:


Warning Message Accessing Magento 2 Admin Panel Dashboard



Due to this warning message, you will not be able to log in to the Magento 2 Admin Panel Dashboard. Unfortunately, Magento 2.4 and greater versions do not provide an option to disable Two-Factor Authentication (2FA). But you can disable the 2FA by following any of the command line methods from your Magento 2 root directory.

Command Line Method #1: Magento 2 Admin Login & Disabling 2FA Temporarily

The first command line method for disabling 2FA temporarily from your Magento 2 root directory is done by issuing the following command:

php bin/magento module:disable Magento_TwoFactorAuth

bin/magento cache:flush

Command Line Method #2: Magento 2 Admin Login & Disabling 2FA Temporarily

The second command line method for disabling 2FA temporarily from your Magento 2 root directory is done by issuing the following command:

bin/magento config:set twofactorauth/general/enable 0

bin/magento cache:flush

Command Line Method #3: Magento 2 Admin Login & Disabling 2FA Temporarily

The third command line method for disabling 2FA temporarily from your Magento 2 root directory is done by taking the following steps:

  1. Open the app folder -> etc -> config.php using any of the text editors (for example the VI Text Editor) from your Magento 2 root directory:

 vi <Magento 2 root directory>/app/etc/config.php 


  1. Find 'Magento_TwoFactorAuth' => 1, and replace with 'Magento_TwoFactorAuth' => 0, 


  • Where you use a value of for disabling 2FA and a value of 1 for enabling 2FA.

      3. Clean the cache by the following command:

bin/Magento cache:flush 


Now you will be able to log into the Magento Admin Panel Dashboard without using Two-Factor Authentication (2FA).

Installing Magento 2 via Composer or a ZIP/TAR Archive File

You can install Magento 2 either using Composer or downloading an archive file for the Magento-specific version in either ZIP or TAR archive file format. But please note that installing Magento from an archive lacks the advantages of using Composer, including reusing third-party libraries without wrapping them with source code, reducing extension conflicts and compatibility issues by using a component-based architecture with robust dependency management, etc. In addition, you should install Elasticsearch before installing Magento 2.4, and Magento does not support Elasticsearch versions 2.x, 5.x, and 6.x.

Installing Magento 2 via Composer


To install Magento 2 using Composer, you can follow the below steps.

Installing Magento 2 via Composer Step #1: Install Composer 

You can run the following scripts in the terminal to install Composer in the current directory: 

#To download the installer to the current directory


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"


#To verify the installer SHA-384


php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"


#To run the installer


php composer-setup.php


#To remove the installer


php -r "unlink('composer-setup.php');"


These installer scripts will check some php.ini settings, notify you if they are set incorrectly, and then download the latest composer.phar in the current directory. 

If you want to put the composer.phar into a particular location as per your requirement, you can call composer from any location such as the following directory:

mv composer.phar /usr/local/bin/composer


Issue the composer --help command to see available options for specific environments.

Installing Magento 2 via Composer Step #2: Install Magento 2.4.


To install Magento 2.4 via Composer, you can run the following commands in the current directory:

composer create-project --repository-url=https://repo.magento.com/magento/project-community-edition:2.4.0 .


You can choose the Magento version in the command shown above as per your requirement by replacing the 2.4.0 with the version you wish to install.


bin/magento setup:install --base-url=http://example.com --db-host=localhost --db-name=<db_name> --db-user=<db_user> --db-password=<db_password> --admin-firstname=Admin --admin-lastname=Admin --admin-email=<your_email> --admin-user=admin --admin-password=<your_password> --use-rewrites=1 --elasticsearch-host=<elasticsearch-hostname> –-elasticsearch-port=<elasticsearch-port> --backend-frontname="admin" --db-prefix=mage_ 


You can run the following commands in the Magento root directory to set file permissions: 


find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} +


find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} +


chown -R <owner>:<group> . 

chmod u+x bin/magento


Issue the bin/magento list command to display a complete list of commands. Issue the bin/magento help <command> to get help for a particular command.


Magento 2.4 Requirements


  • Mail Server: Mail Transfer Agent (MTA) or an SMTP Server.
  • Operating Systems (Linux x86-64):  Linux distributions, such as RedHat Enterprise Linux (RHEL), CentOS, Ubuntu, and Debian. Magento is not supported on Microsoft Windows and macOS.
  • PHP Extensions: ext-bcmath,ext-ctype, ext-curl, ext-dom, ext-fileinfo, ext-gd, ext-hash, ext-iconv, ext-intl, ext-json, ext-libxml, ext-mbstring, ext-openssl, ext-pcre, ext-pdo_mysql, ext-simplexml, ext-soap , ext-sockets, ext-sodium, ext-xmlwriter, ext-xsl, ext-zip, lib-libxml, lib-openssl.
  • PHP OPcache: The OPcache is enabled in many PHP distributions and is recommended for performance reasons.
  • PHPUnit: PHPUnit (as a command-line tool) 9.0.0
  • RAM: Magento applications and extensions upgrade requires up to 2GB of RAM. If the system has less than 2GB of RAM, you will need to create a swap file to avoid upgrade failure. 
  • System Dependencies: bash, gzip, lsof, mysql , mysqldump, nice, php, sed, tar.
  • SSL: A valid security certificate is required for HTTPS.


Conclusion

If you are looking for a suitable Magento hosting plan for your website, you are in the right place. At Nexcess, we offer optimized ecommerce hosting solution built for speed, security, and scale. You can find the available Fully Managed Magento Hosting plan on the Nexcess website. We also install Magento 2 for our customers as per their requirements using our own customized nkmagento2 command from our side. In addition, our skilled team provides 24/7/365 support and monitoring services so that you can focus on your websites. Contact our team today to learn more.

Not a Nexcess Customer Yet?


Nexcess Managed Hosting offers you many benefits from security and performance scanning, automated maintenance, and updates to beautiful, customizable designs and 24/7/365 support. Furthermore, Nexcess offers three flagship managed platforms to choose from:



Partner with us by letting us help you implement one of our many excellent, fully managed hosting solutions. Have more questions? Our experts are here to help

Managed Magento Hosting Plans

Before we get started, you may refer to the Managed Magento Hosting page to get an idea of our plans if you are in the market for a web hosting provider.  

Consider Hosting with Nexcess


Hosting optimized for the industry's leading platforms, including Managed WordPress Hosting, Managed WooCommerce Hosting, and Managed Magento Hosting.

Read more about the Fully Managed Magento Hosting and its benefits for your business.

Optimized Ecommerce Hosting for Speed, Security and Scale

It’s hosting optimized for WordPress. That means a faster, more secure and scalable website. Smart monitoring tools are built-in to help you keep it that way. 

It’s why WordPress Users Trust Nexcess Hosting.

We also have a variety of Nexcess support articles about Magento 2. Our range of hosting plans caters to any business scale. We do all the heavy lifting for you to focus on growing your business. In addition, we automatically update ore components and plugins to the latest version and ensure your hosting environment is properly optimized, secured, and updated.


Nexcess infrastructure was specially designed to keep up the best speed and performance in the industry. No traffic surge can threaten your website to go down thanks to our autoscaling technology which adds more resources to your server to handle the load. In addition, we offer always-on security monitoring and support from web hosting experts 24/7/365 and a built-in CDN with 22 locations and advanced caching for ultra-fast loading.


All hosting plans include The Nexcess 30-Day Web Hosting Money Back Guarantee.


Need a No-Code Website Building Solution? 


Are you on an accelerated schedule and already ready to move forward? If you need to get started with your Nexcess StoreBuilder Solution sooner rather than later, check out these resources:


Next Steps with a Nexcess Cloud Hosting Solution?

Read more about the Fully Managed Cloud Environment by Nexcess and its benefits for your business.

A Cloud Hosting Solution That Lets You Do Business Your Way 

We believe in the promise of cloud: scalability, security, performance, and ease of use. Together with our team, clients, and partners, we’ve built something better.

Choose From Multiple Applications 

Whether you’re a small business or a high-traffic eCommerce store, our cloud hosting solutions are designed around your needs: auto scaling, PCI compliance, and comprehensive development tools provide you with maximum dynamic flexibility in a fully managed cloud environment.


We make applications easy with environment optimizations for:

And there are many more!


We also have a variety of Nexcess support articles about how best to implement our product offerings housed in the Nexcess Knowledge Baseincluding how to get your site going with a number of different configuration options. 

24-Hour Assistance

If you need any assistance with the above-mentioned, don't hesitate to reach out. For 24-hour assistance any day of the year, Nexcess customers can contact our support team by email or through your Client Portal.

Why Choose Nexcess?

Because we're different! Chris Lema captures "the why" in his passionate and stirring recount of a Nexcess support-related story.



Useful YouTube > Nexcess Channel Links

Resources for More Information

Need more help? The Applications > Magento 2 and Magento 1 sections within the Nexcess Knowledge Base are important resources for those seeking additional knowledge.

The Applications section also contains valuable insights for those seeking additional knowledge about our other various hosted applications and platforms. Check out our related video playlists and articles below:


Related Articles



Mohammed Noufal
Mohammed Noufal


Mohammed Noufal is a B.Tech graduate with a decade of experience in server administration and web hosting. He has a specialization in various cloud technologies and server management, including monitoring, configuring, troubleshooting, and maintenance.

He is a father to two daughters and finds fulfillment in their growth. In his free time, he enjoys blogging about technology, sharing experiences, traveling, making new friends, social networking, and listening to music.

With a strong technical background, family commitment, and creative outlets, he represents a well-rounded life journey.

We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.