How To Secure Apache2 With LinOTP

This Howto describes the way to set up two factor authentication with one time passwords for Apache2. We assume, that you have already set up your LinOTP server. You can download Debian and Ubuntu packages or you can install the system using the Python Package Index. It provides a good quick start to get the service up and running for demo purposes (check for the latest version).



The OTP authentication is done using a Apache authentication provider for Apache basic authentication. This provider can be downloaded at github.

Or you can download the package directly at your command line:

wget -O



You need at least the following packages on your Ubuntu or Debian system to compile the Apache module:

dpkg -i libtool automake autoconf build-essential libcurl4-gnutls-dev

Now unzip the module and enter the directory:

cd lsexperts-mod_authn_linotp-3583b90

The installation process is also described in the file INSTALL:

automake --add-missing
sudo make install

You can also use checkinstall to create a debian package for easier package handling.

sudo checkinstall make install

Now the module is located at /usr/lib/apache2/modules/


Activate the module

sudo a2enmod authn_linotp


Configure Apache

Now you can use two factor authentication for your Apache directories and locations. You can also take a closer look at the file README for all the configuration parameters.

The module uses cookies to cache the successful authentication. The cookie is encrypted, so you need to create a secret:

pwgen 24 1

Now you can protect any Directory or Location scope like this:

<Directory />
    AuthType basic
    AuthName "LinOTP protected"
    AuthBasicProvider LinOTP
    Require valid-user
    LinOTPCookieSecret  eenohJaen6CeexaH9yieTiel
    LinOTPSSLCertVerify Off
    LinOTPSSLHostVerify Off

Using LinOTPTimeout you can define for how many seconds the cookie should be valid and thus after which time the user should be asked for a new OTP again.

Please note: Using localhost in you LinOTPValidateURL might lead to curl errors, so please either use the correct IP or FQDN.

Happy Authenticating!

Share this page:

2 Comment(s)

Add comment

Please register in our forum first to comment.


By: Souva

sudo apt-get install libcryptosudo apt-get install apache2-dev

if you can't make


By: jimmy ruffin

 dpkg -i libtool automake autoconf build-essential libcurl4-gnutls-dev command give me this output Errors were encountered while processing: