Set Up Google Authenticator 2FA on a Linux System

avatar

In this blog, we will learn how we can set up Google 2FA authentication on a Linux operating system, which means that if you want to be more secure, when you log in to the Linux system after entering the root password, it will also ask for Google 2FA authentication. The process will work on all Debian-based Linux operating systems such as Ubuntu, Kali Linux, Debian, ParrotOS, Linux Mint, etc.

  1. Open Terminal on your Linux machine and update and upgrade your packages, process the command-

    sudo apt update && apt upgrade
    
  2. Install the Google 2FA authentication

    sudo apt install libpam-google-authenticator 
    

  3. Now, configure the Google 2FA authentication

    google-authenticator
    

    Type y and press enter to continue

  4. You will get a QR code and the secret key to set up on your Google 2FA authenticator Mobile app.

  5. Now install Google Authenticator on your phone from the Google Play Store or Apple App Store.

  6. Now time to scan the QR code; it will add to your Google Authenticator app.

  7. Type the same code on your terminal and press Enter.

  8. You will get 5 emergency scratch codes. If you have lost your phone or your phone is not nearby, then you can also unlock your system with these codes. Save it securely outside of this system, and type Y and press Enter.

  9. It will ask 3 more times for the confirmation; just type Y and press Enter.

  10. Now, clear the terminal, and time to configure the Google 2FA in the system. process the command-

    sudo nano /etc/pam.d/gdm-password
    
  11. It will open the nano editor, where we have to add an entry at the bottom.

    auth required pam_google_authenticator.so
    

    To save this file, press Ctrl + O, then Enter, and to exit, press Ctrl + X. and close the terminal.

  12. Now it's ready, logout the system, and in login time after entring the root password it will ask the 2Fa authention code, just open the Google authenticator app and enter the code, your system will be unlock.

You can also watch the video tutorial for this.



0
0
0.000
3 comments
avatar

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

image.png

100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited.

0
0
0.000
avatar

Congratulations @an1info! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You received more than 3750 upvotes.
Your next target is to reach 4000 upvotes.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Feedback from the July Hive Power Up Day
Hive Power Up Month Challenge - June 2026 Winners List
Be ready for the July edition of the Hive Power Up Month!
0
0
0.000