Magento 2 Disable Two Factor Authentication Module

From Magento 2.4.x, the 2-factor authentication for the admin is by default enabled. In some situations, if you are not able to set up 2 factor authentication for your admin user then you can not log in to the Magento admin. These situations such as you are setting up Magento 2.4.x in the localhost, or you are creating a new admin user in any server in which emails are not sent, or you do not have access to the email account.

In this situation, you can disable the 2-factor module on a temporary basis to access Magento 2 admin.

Steps to disable 2-factor authentication module in Magento 2
Step 1: Connect to SSH of your Magento 2 website or open CMD in your localhost.
Step 2: Move to website docroot
Step 3: Run following commands and that’s it.
php bin/magento module:disable Magento_TwoFactorAuth
php bin/magento setup:upgrade

Run following commands only if your Magento mode is production
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy

NOTE: This is an extra security feature so we recommend not disabling it on the production website.