install the Google Authenticator on your phone. You can download it from the Google Play Store or the Apple App Store.
Once the repositories are updated, you can proceed to the next step.
Next, you need to install the Google Authenticator PAM module on your Linux system. You can do this by running the following command:
Once the module is installed, you need to configure it for your user. Run the following command:
Finally, you need to update the PAM configuration to enable Google Authenticator for SSH logins. Edit the sudo nano /etc/pam.d/sshd file and add the following line at the end:
You also need to modify the sudo nano /etc/ssh/sshd_config file.
Search for "challenge-response" there you will find something like the below screenshot change KbdInteractiveAuthentication (or sometimes named as ChallengeResponseAuthentication) to yes and uncomment the "PasswordAuthentication yes"
Save the file and restart the SSH service to apply the changesImportant Do not close the current ssh session before testing!
Now open a new shell using putty for instance and test if it works, when you log in to your Linux system via SSH, you will be prompted to enter a verification code from the Google Authenticator app on your phone in addition to your password.
If this is succesfull you can close the other ssh session and you are done!