Skip to main content

Install 2FA on Raspberry Pi

Here are the command you need to install 2FA on Raspberry Pi.

sudo apt install libpam-google-authenticator 

Now Run Google Authenticator

google-authenticator
sudo nano /etc/pam.d/sshd

Next you need to add the following before or after the @include common-auth

auth required pam_google_authenticator.so

Putting it before or after does make a difference.  If it is after you will be prompted for a password first. If it is before you will be asked for you verification code.

Next thing that needs to be changed the line in your /etc/ssh/sshd_config.  Either vi or nano to the file and change the following line to say yes sometimes is it also commented out remove the # before the line if it exists:

KbdInteractiveAuthentication yes

Once that is finished you will need to restart the ssh service and check to see if there are any errors:

sudo systemctl restart ssh
sudo systemctl status ssh