Set Up Google Authenticator 2FA on a Linux System

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.01480862 BEE
0 comments