<span class="warning"><p></p>

				
					&lt;div name="status-deprecated" data-unique="status-deprecated"&gt;&lt;/div&gt;&lt;h2 id="status-deprecated"&gt;&lt;strong&gt;Status:&lt;/strong&gt; Deprecated&lt;/h2&gt;
				
			

This article covers a version of Ubuntu that is no longer supported. If you are currently operate a server running Ubuntu 12.04, we highly recommend upgrading or migrating to a supported version of Ubuntu:

  • Upgrade to Ubuntu 14.04.
  • Upgrade from Ubuntu 14.04 to Ubuntu 16.04
  • Migrate the server data to a supported version

Reason: Ubuntu 12.04 reached end of life (EOL) on April 28, 2017 and no longer receives security patches or updates. This guide is no longer maintained.

LinOTP is a two-factor authentication solution to manage devices that require enhanced security. It runs on a Python web framework, so you’ll need to setup a MySQL database to use it. This article only covers installation on the 12.04 LTS version of Ubuntu.

Installing and configuring MySQL

linotp illustration for: Installing and configuring MySQL

To install the MySQL server on an Ubuntu VPS, run:

				
					sudo apt-get install mysql-server
				
			

During the install, you’ll be prompted to insert a root password, like so:

<img src="images/how-to-install-linotp-on-an-ubuntu-vps-section-1.png; alt="Prompt for password">

Remember this; you’ll need it on the next step. Now, you’ll need to create a database for LinOTP. Refer to the How to Create a Table in MySQL article if you have any doubts on this part. To enter the MySQL console, run:

				
					mysql -u root -p
				
			

And enter the password. Now paste and execute the following lines to create the table, remembering to change “ChangeThis” to a strong password:

				
					CREATE DATABASE LinOTP2;

GRANT ALL PRIVILEGES ON LinOTP2.* TO 'linotp2'@'localhost' IDENTIFIED BY 'ChangeThis';

FLUSH PRIVILEGES;
				
			

You can now exit the MySQL console by running:

				
					exit
				
			

Installing and configuring LinOTP

We’ll proceed to add LinOTP’s repository. As of this writing, this is only supported on Ubuntu 12.04 LTS. First, install the package that allows you to run the “add-apt-repository command”:

				
					sudo apt-get install python-software-properties
				
			

Now, add the repository by running the following command:

				
					sudo add-apt-repository ppa:linotp/stable
				
			

You’ll be asked for confirmation. Simply press Enter. You now should be able to update the repositories:

				
					sudo apt-get update
				
			

If you don’t see an error, that means you are running the right version of Ubuntu and can proceed to install LinOTP. Now that you have the repository added, simply run:

				
					sudo apt-get install linotp
				
			

to install LinOTP. You’ll be prompted a series of questions. In this tutorial, we won’t cover the Apache configuration, so when asked if you want to run LinOTP via Apache2, answer “No” as shown:

<img src="images/how-to-install-linotp-on-an-ubuntu-vps-section-1.png; alt="Prompt for Apache">

As we’ve already installed MySQL before, select the SQL database LinOTP stores its data as MySQL:

<img src="images/how-to-install-linotp-on-an-ubuntu-vps-section-1.png; alt="Prompt for SQL server">

Set “localhost” as the hostname to the MySQL server, as you’re running it on the same VPS. Leave the database name as LinOTP2 as it’s the name we chose earlier:

<img src="images/how-to-install-linotp-on-an-ubuntu-vps-section-1.png; alt="Prompt for database">

Leave the database user as “linotp2”, and type in the password you chose earlier (not the one from the root user for the MySQL server). You’ll be asked if you’d like to create the database tables, answer “Yes”. The installation should finish after a few seconds. Then, run the following command to finalize LinOTP’s configuration:

				
					sudo paster setup-app /etc/linotp2/linotp.ini
				
			

Running LinOTP

To run LinOTP, simply type in:

				
					sudo paster serve /etc/linotp2/linotp.ini
				
			

Now you should be able to access the LinOTP management interface from your browser by going to the following address:

				
					http://your.droplet's.ip:5001/manage
				
			

From there, you can enroll your first token.

Conclusion

Security has always been a very sensitive topic. It’s indispensable to have measures that protect yours and other’s data. Two-factor authentication is a very good form of doing just that, and LinOTP makes it really easy.