Secure authentication with one-time passwords
The next step is to integrate the authentication mechanism with the PAM stack (see Listing 2). The pam_unix or pam_unix2 modules do most of the work. These modules are tagged with a sufficient control flag, but as you want to replace the pam_unix.so or pam_unix2.so libraries with the pam_opie.so library, you should modify the configuration accordingly.
01 ... 02 auth sufficient pam_opie.so 03 # You can leave out this line if you have tested OPIE: 04 auth sufficient pam_unix.so nullok try_first_pass 05 ...
Note that it is possible to configure your system so that, if OPIE fails for any reason, users can still use legacy passwords to authenticate.
Once you have modified the PAM configuration, your system is OTP-capable. Some services, such as the SSH daemon, still need some manual attention before they start using one-time passwords. In the case of SSH, you need the following line in the server configuration file /etc/sshd/sshd_config:
Listing 3 shows an SSH login using OPIE. After successfully authenticating, OPIE updates the /etc/opiekeys file, adding the new sequence number and the hash of the last password used.
SSH Login with OPIE
01 $ ssh email@example.com 02 otp-md5 498 te5843 ext 03 Response: 04 # cat /etc/opiekeys 05 root 0498 te5843 2b84befd37cacb9f Feb 16,2008 05:58 06 #
Sowing and Harvesting
Users need opiekey to generate one-time passwords. The generator in Listing 4 expects the user password, the seed, and the current sequence number. Users can run opieinfo to view this information. OPIE also has a mechanism that generates a list of OTPs in case a user doesn't have a generator.
Creating three OTPs with opiekey
01 # opieinfo 02 497 te5843 03 # opiekey -5 -n 3 `opieinfo` 04 Using the MD5 algorithm to compute response. 05 Reminder: Don't use opiekey from telnet or dial-in 06 sessions. Sorry, but you don't seem to be on the 07 console or a secure terminal. 08 Warning: Continuing could disclose your secret pass 09 phrase to an attacker! 10 Enter secret pass phrase: 11 495: MUSH ACT GRIM SEE MAID LIES 12 496: HAD FED WORD ROY STAB ACID 13 497: IO INK RIG DAME RULE TUM 14 #
Other generators in addition to opiekey are also available. The Java program JOTP  will run on a Java-capable cellphone or on a normal website, although the website must be trustworthy. Palm owners can run Palmkey  or Pilotp , and desktop users can run Optcalc .
The opiepasswd -d command disables a user entry in /etc/opiekeys and thus bans the user from the OPIE system (see Listing 5). The system overwrites the password hash with a series of asterisks (*), although the sequence number and seed remain visible.
Disabling OPIE for a User
01 user1@rechner$ opiepasswd -d 02 Updating user1: 03 Disable user1's OTP access? (yes or no) yes 04 ID user1 is disabled. 05 user1@rechner$ su - 06 Passwort: 07 # grep user1 /etc/opiekeys 08 user1 0359 te2880 **************** Feb 16,2008 08:37 09 #
Pluggable Authentication Modules (PAM)
PAM defines four categories for the authentication process: auth, account, password, and session. The auth category handles the authentication itself, while password defines whether and how a user can change their password. PAM uses account to manage access based on the user account and session to handle the environment setup.
PAM has a selection of various modules in each category and organizes them in a stack. Each module is tagged with a control flag. This approach lets admins define how PAM reacts to successful or unsuccessful processing of a module. The following flags exist: required, requisite, sufficient, and optional. If a module flagged required, requisite, or sufficient fails, the complete authentication process fails. If the module is tagged requisite, PAM immediately stops processing the stack.
After successfully processing a module flagged required, requisite, or optional, the next PAM library steps up. PAM views the category as successfully processed if the module is flagged sufficient.
The OTPW Alternative
The OTPW software-based solution does not use the method specified by RFC 2289 but relies instead on a 160-bit version of the RIPEMD hash. OTPW includes a modified version of the program login (demologin) and an alternative module for integration with the PAM stack. Users are issued passwords in the form of a list, which is similar to the legacy TAN lists issued by banks.
When authenticating, the user types a string comprising the list entry and their own password. The OTPW server stores the RIPEMD hashes of all valid one-time passwords (along with a number) in the .otpw file below the user's home directory. The program overwrites used passwords with dashes, thus preventing reuse.
The OTPW package is far smaller than OPIE; the source code comprises just 18 files. A simple make will create the demologin and otpw-gen programs, as well as the pam_otpw.so PAM library.
For Linux systems with PAM, OTPW requires only the otpw-gen generator and the pam_otpw module. The user initializes the OTPW system by running otpw-gen (Listing 6). After entering a password, otpw-gen creates a list of OTPs and displays the results.
Setting up OTPW
01 # otpw-gen -h 5 02 Generating random seed ... 03 04 If your paper password list is stolen, the thief should not gain 05 access to your account with this information alone. Therefore, you 06 need to memorize and enter below a prefix password. You will have to 07 enter that each time directly before entering the one-time password 08 (on the same line). 09 10 When you log in, a 3-digit password number will be displayed. It 11 identifies the one-time password on your list that you have to append 12 to the prefix password. If another login to your account is in progress 13 at the same time, several password numbers may be shown and all 14 corresponding passwords have to be appended after the prefix 15 password. Best generate a new password list w en you have used up half 16 of the old one. 17 18 Enter new prefix password: 19 Reenter prefix password: 20 21 Creating '~/.otpw'. 22 Generating new one-time passwords ... 23 24 OTPW list generated 2008-03-16 10:23 on testvm3.seidelnet.de 25 26 000 a7Sj rWoC 001 %URK VvmD 002 EoQa sgon 003 IQhJ kVMG 004 QsS% H=aU 27 28 !!! REMEMBER: Enter the PREFIX PASSWORD first !!! 28 #
The -p1 parameter tells otpw-gen to output the OTPs as a list of four-letter words, for example:
hare lane fyfe self lucy
Deleting the .otpw file disables the use of one-time passwords for the account.
It makes sense to print the list. Users are responsible for keeping track of how many valid one-time passwords they still have.
If you want to save paper, check the content of .otpw when you log in. Used OTPs are tagged with -. Integration of OTPW with the PAM system follows the same steps as for OPIE.
According to the documentation, adding this entry
session optional pam_otpw.so
tells OTPW to let you know how many OTPs you have left when you log in. This command did not work in our lab. The manual steps for the SSH daemon are similar to those for OPIE.
Users create one-time passwords by concatenating their user passwords with the strings in the list generated by otpw-gen.
When a user attempts to log in, OTPW creates a symbolic link for .otpw.lock in the user's home directory. If the user cancels the login attempt by pressing Ctrl+C, the symbolic link is kept. The user is locked out while the link exists, as it prevents the use of OTPW.
On top of this, OTPW does not normally support simultaneous logins for security reasons. According to the program documentation, the user enters an extended one-time password in this case. The extended OTP comprises the user password and three strings from the list. We were unable to test this behavior in our lab.
One-time passwords are useful for insecure environments with a danger of password sniffing. The OPIE and OTPW implementations are easily integrated with popular Linux distributions thanks to PAM.
- Digipass 300 Pro: http://www.vasco.com
- RSA Secur ID: http://www.rsa.com
- Onetime Password In Everything (OPIE): http://www.inner.net/opie
- One-Time Password (OTPW): http://www.cl.cam.ac.uk/~mgk25/otpw.html
- Pluggable Authentication Modules (PAM): http://www.kernel.org/pub/linux/libs/pam/
- Java OTP Calculator (JOTP): http://www.cs.umd.edu/~harry/jotp/
- Palmkey: http://palmkey.sf.net
- Pilot OTP Generator: http://www.valdes.us/palm/pilOTP/
- OTP and S/Key Calculator for X-Window: http://killa.net/infosec/otpCalc/
Buy this article as PDF
Report from the X-Force group says attackers are using TOR to hide their crimes
Future Firefox extensions will be compatible with Chrome.
Better read this if you bought your computer before 2011
Users should upgrade to the new version as soon as possible
Xen project announces a privilege escalation problem for Qemu host systems
Attackers can compromise an Android phone just by sending a text message
PC vendor will pre-install Ubuntu on portables in India.
More embarrassment for Adobe's embattled multimedia tool
Mozilla’s script blocker add-on could be putting malware sites on the whitelist.
The Internet community officially banishes the notoriously unsafe Secure Sockets Layer protocol.