Magento 2.4 upgrade - unlock admin 2FA login and elasticsearch engine connection

Unlock 2FA login

Upgraded to Magento 2.4 and we are going to login to Magento backend. This will ask for user and password, as always, but after we login successfully, we will see that email was sent to you about 2FA login configuration.

What to do if you don’t have mail configured on your Magento system, then there is no way to get the authenticator link?

Login to your server, and go to Magento docroot folder. Locate the Magento 2 CLI, and run this command:

 

$ G2FA_CODE="$(head -c 500 /dev/urandom | tr -dc 'a-zA-Z0-9$#&' | fold -w 15 | head -n 1 | base32)"
$ bin/magento security:tfa:google:set-secret admin ${G2FA_CODE}

 

If you see this message Google OTP secret has been set This means you have successfully configured Google Authenticator for 2FA login in your Admin panel.

Now you have a Base32 encoded string:

 

$ echo ${G2FA_CODE}

 

Open your Google Authenticator (iOS | Android ) app on your mobile, add new account and follow on screen instructions.

 

Unlock ElasticSearch engine


It is just as easy to activate elasticsearch if you have upgarded the Magento 2.4 before installing the ELK.

Login to your server, and go to Magento docroot folder. Locate the Magento 2 CLI, and run this command:

$ bin/magento config:set catalog/search/engine 'elasticsearch7'
$ bin/magento config:set catalog/search/elasticsearch7_server_hostname 'localhost'
$ bin/magento config:set catalog/search/elasticsearch7_server_port '9200'
$ bin/magento config:set catalog/search/elasticsearch7_enable_auth '1'
$ bin/magento config:set catalog/search/elasticsearch7_username 'elastic'
$ bin/magento config:set catalog/search/elasticsearch7_password 'PASSWORD_HERE'
Clean Magento 2.4 cache and run the setup:upgrade to finish the setup.