Howto install LinOTP with ubuntu 10.04 to secure your desktop with OTP
----------------------------------------------------------------------

We will setup local authentication on your standalone desktop
to be secured using one time passwords with LinOTP.

!! Please note that in this case, every local user on your machine has
access to configure the LinOTP service. If you need to setup LinOTP
with more restrictions or in an enterprise environment, you should 
setup LinOTP within the apache webserver and an SQL server token
database.
The setup in this howto does only use the paster webserver and an 
sqlite database file.

This setup was well tested with Ubuntu 10.04. It should also work
with debian squeeze.

0. Prerquisites
---------------
You need the packages 

    linotp_2.2_all.deb
    linotpuseridresolver_2.2_all.deb
    libpam-linotp_2.2_i386.deb
    linotpadminclientce_2.2-pre2_all.deb

The following dependencies need to be installed:

python-simplejson python-crypto python-docutils python-sqlalchemy python-pylons python-tempita python-weberror python-webob python-mako python-nose python-decorator python-formencode python-pastescript python-pastedeploy python-paste python-beaker python-webhelpers python-routes python-pygments python-ldap python-mysqldb python-m2crypto apache2 libapache2-mod-wsgi python-repoze.who pwgen mysql-server

We recommend to install the mysql-server to achieve a more stable linotp installation. Using apache2 you get authentication and due to threading it is not possible to use SQLite with LinOTP running under apache2.

1. Installation
---------------
Install the packages by issuing the command

    dpkg -i linotp_2.2_all.deb linotpuseridresolver_2.2_all.deb libpam-linotp_2.2_i386.deb linotpadminclientce_2.2_all.deb

When installing linotp_2.2_all.deb you will be asked several questions.

  Do you want to run LinOTP 2 via Apache2? 
	-> Yes
  Enter admin password for the new LinOTP admin account.
  	-> think of one
  Do you want to create a self signed ceritficate?
  	-> Yes
  What SQL database do you want to use for the token database?
	-> Mysql
  database hostname:
  	-> localhost
  Name of Token database
  	-> LinOTP2
  database user
  	-> linotp2
  database users password:
  	-> think of one
  Enter my sql root password
  Do you want to create the tables
  	-> yes

Then the encryption key /etc/linotp2/encKey and the database file
/etc/linotp2/token.db will be created.

you will be able to see the management interface by
pointing your browser to 

  https://localhost/manage/index
  
If you get an "Internal Server error", assure, that the complete directory
/etc/linotp2 is owned by the user linotp.


2. Configuration
----------------
You may use the management web ui or the command line client to setup your
linotp server

You need to configure a UserIdResolver and a default realm. You may do this
by issuing the following commands.

    linotpadm.py --url=https://localhost --admin=admin --command=setresolver --resolver=defaultPW --rtype=FILE --rf_file=/etc/passwd
 
That reads the users from the /etc/passwd file. 
You will get a JSON feedback like this:

{ u'status': True,
  ....}
  
Now you need to add this resolver to your default realm:

    linotpadm.py --url=https://localhost --admin=admin --command=setrealm --realm=defRealm --resolver=useridresolver.PasswdIdResolver.IdResolver.defaultPW
    linotpadm.py --url=https://localhost --admin=admin --command=setdefaultrealm --realm=defRealm 
 
You can either check it in the web ui or issue the command

    linotpadm.py --url=https://localhost --admin=admin --command=listuser

Now you are ready to assign tokens to your users.

3. Enroll OTP Token
-------------------

You way want to enroll an OTP. In this example we enroll an motp token on our mobile phone.
Download the app from http://motp.sourceforge.net and install it on your phone.
You may initialize the token by entering 0000 as PIN on the phone.

An init-secret will be displayed.

    linotpadm.py --url=https://localhost --admin=admin --command=inittoken --user=cornelius --type=motp --otpkey=860e2e9bf9d50665 --serial=1 --otppin=1234

This means, that you generated an mOTP token that gets assigned to the user "cornelius". The otpkey is the init-secret that was displayed on your phone. You may choose a serial (serial number) as you like to.
The otppin is the PIN you will enter on the phone to generate an otp value.

Optionally you may set an OTP PIN, which is a fixed password part, that you need to enter in front (Depending on the parameter PrependPIN) of the OTP value.

    linotpadm.py --url=https://localhost --admin=admin --command=set --pin=Password --serial=1

Now got to generate your first OTP value!

Now go to the portal site

https://localhost/auth/index

and enter your username and as password the OTP PIN you set and the otp value you generated with your phone.

If you fail to authenticate, you might mistyped the init secret or the time of your phone might be out of sync.

4. Authenticate via PAM
-----------------------
Now we will setup PAM to enable you to authenticate to your desktop.

The security module /lib/security/pam_linotp.so was installed to your system. 
You may now setup otp authentication
We choose to do it modular:

 cp /etc/pam.d/common-auth /etc/pam.d/common-linotp
 
In /etc/pam.d/common-linotp change the line:

auth    [success=1 default=ignore]      pam_unix.so nullok_secure

to

auth    [success=1 default=ignore]      pam_linotp.so debug nosslhostnameverify nosslcertverify url=https://localhost/validate/simplecheck realm=defrealm resConf=defaultPW

Please note, that when using "debug" option, many many information - also the Password! - will be written to the auth.log.

You may now use the common-linotp in any PAM configuration instead of common-auth, where you like to.
I.e. you may change the line in /etc/pam.d/gdm 

@include common-auth

to

@include common-linotp

Now you will need to authenticate with OTP to your Gnome desktop!

Note that you will also need to change /etc/pam.d/gnome-screensaver if you also want to unlock the
desktop using OTP:
You will not be asked for "Password" anymore but for "Your OTP".

If you fail to authenticate you may also take a look into /var/log/auth.log


 
 
