Step 1: Install Google Authenticator
sudo apt install libpam-google-authenticator -yStep 2: Configure PAM
sudo nano /etc/pam.d/sshdAdd at the top:
auth required pam_google_authenticator.soStep 3: Edit SSH Config
sudo nano /etc/ssh/sshd_configSet:
ChallengeResponseAuthentication yes
AuthenticationMethods publickey,password publickey,keyboard-interactiveStep 4: Run Google Authenticator for User
google-authenticatorScan the QR code with your authenticator app.
Step 5: Restart SSH
sudo systemctl restart sshd