Enable Google Authenticator 2FA for SSH

· 1 min read
Enable Google Authenticator 2FA for SSH

Ubuntu:

$ sudo apt-get install libpam-google-authenticator

Debian:

$ sudo apt-get install libqrencode3
$ wget http://ftp.us.debian.org/debian/pool/main/g/google-authenticator/libpam-google-authenticator_20191231-1_amd64.deb
$ sudo dpkg -i libpam-google-authenticator_20191231-1_amd64.deb

Configure:

$ google-authenticator

$ sudo vi /etc/pam.d/sshd
Add to the bottom:
auth required pam_google_authenticator.so

$ sudo vi /etc/ssh/sshd_config
Set ChallengeResponseAuthentication yes

$ sudo /etc/init.d/ssh restart