Skip to content

Instantly share code, notes, and snippets.

@rafaelfoster
Last active January 4, 2016 20:39
Show Gist options
  • Save rafaelfoster/8675479 to your computer and use it in GitHub Desktop.
Save rafaelfoster/8675479 to your computer and use it in GitHub Desktop.
Linux - PAM Google Two Factor Module
# RHEL based
yum install gcc make pam-devel
# Debian Based
apt-get install build-essential make libpam0g-dev libpam0g; LDFLAGS="-lpam"
version=1.0
mkdir ${HOME}/tmp
cd ${HOME}/tmp
wget https://google-authenticator.googlecode.com/files/libpam-google-authenticator-$version-source.tar.bz2
tar xjvf libpam-google-authenticator-$version-source.tar.bz2
cd libpam-google-authenticator-$version
make
make install
echo Y | google-authenticator -d -t -r 1 -R 30 -f -w 10
#/etc/ssh/sshd_config
# Tips to enforce SSH access
DenyUsers root@!192.168.*.*
# Change to no to disable Password requirement (usable to combine OTP + Keys Login)
PasswordAuthentication no
# Change to no to disable s/key passwords
ChallengeResponseAuthentication yes
#/etc/pam.d/sshd
#%PAM-1.0
auth include google-otp
#/etc/pam.d/google-otp
auth required pam_unix.so
# If the user is NOT in group "otp_auth", skip next module
auth [success=1 default=ignore] pam_succeed_if.so user ingroup otp_auth
auth required pam_google_authenticator.so secret=${HOME}/.google_authenticator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment