Google Authenticator is a software-based authenticator that generates codes for your accounts. It is based on 2FA (2-Factor Authentication) to ensure the security of your accounts beyond the username and passwords. It is important as it prevents cybercriminals from accessing your accounts. If you enable 2FA for your account, you will require two forms of identification: a password and a 2FA code generated by Google Authenticator. Do you want to protect your Linux system by enabling 2FA? Install the Google Authenticator application on Linux Mint 21 using the command line.
How to Install Google Authenticator on Linux Mint 21
Google Authenticator generates a one-time passcode for your account based on 2 FA every time you log in to your account. Google Authenticator is available as a pre-built package on Linux; it contains Google Authenticator binary and PAM (pluggable authentication) modules.
Step 1: Install Google Authenticator via Apt
Install the pre-built package of Google Authenticator via the below command, type your password and hit Enter:
Allow the installation process to complete. Once completed, set up the Google Authenticator by executing the following command and afterwards allow the time-based tokens:
Before proceeding further, open any Google Authenticator app on your smartphone and add the new account. Scan the appeared QR in the app:
The app will generate a six-letter, enter the code in the terminal:
Once you have added the code generated by the app, some emergency scratch code will appear on your screen:
At the end of the code, some changes asked by Google Authenticator will prompt enter y at the end of each question:
Step 2: Enable 2FA
In order to allow 2FA you must configure SSH on your system. First, enable the PAM module by adding some necessary lines to its file and to open it execute:
Next, add the following lines at the bottom of the opened file:
auth required pam_permit.so
Save the file by pressing Ctrl+O, press Enter key, and exit using Ctlr+X, now you are all set up and ready to use the Google Authenticator.
Wrapping Up
You can secure your Linux Mint system by enabling the 2FA and for that, the best tool is Google Authenticator. Your Linux account is protected with the username and password; however, you can add an additional layer of security so no one can log in to your account. You will have 30 seconds to enter the verification code, if you miss the generated code, the app will regenerate another code for 30 seconds. To enable 2 FA on Linux Mint 21, install the Google Authenticator through Apt.