Setting up a based authentication

The authentication module uses a Berkeley format DB to hold passwords associated with user names.

To create this DB, you need to install the libdb3-util package, which includes the necessary tools.

Please bear in mind that the passwords in this file are not encrypted. Anybody with read access to the DB will be able to dump the passwords.

Here is how you can setup the based authentication:

  • Create a text file with the username and password pairs:

This file will list all username and password pairs, each username being on a first line, with the associated password on the following line.

For example:

  • Convert this text file to a Berkeley DB:
db3_load -T -f users_and_passwords_text_file.txt -t hash userpass.db

This will create a Berkeley DB called “userpass.db” which we can use for PAM authentication.

  • Make sure that only root can read and change this file:
chown root.root userpass.db
chmod 0600 userpass.db
  • Add the call to the PAM module in the appropriate file in /etc/pam.d/:
auth   required    db=/full/path/to/userpass

Please note that the “.db” extension is omitted in the parameter given to the PAM module.

License : CC-BY