Google Authenticator module for Apache

Deprecated document

In case you want to use the Google Authenticator for your website you can do the following:


1. Place in /usr/lib/apache2/modules. (Download from:

# cp /usr/lib/apache2/modules

2. Load the module in apache2 configuration:

Loadmodule authn_google_module /usr/lib/apache2/modules/

3. Create two-factor folder under apache

# mkdir -p /etc/apache2/two-factor

4. Install linux google-authenticator

# apt-get install libpam-google-authenticator

5. run google-authenticator

# google-authenticator

6. Move the authenticator profile to the correct folder and rename it to the username you are going to log in with.

# mv ~/.google_authenticator /etc/apache2/two-factor/MyUserName

7. Add the basic authentication configuration to the vhost config:

AuthType Basic
AuthName "Google Authenticator Code"
AuthBasicProvider "google_authenticator"
Require valid-user
GoogleAuthUserPath /etc/apache2/two-factor/
GoogleAuthCookieLife 3600
GoogleAuthEntryWindow 2

8. Restart apache

# /etc/init.d/apache2 restart