19 June 2015

How To Change Your Forgotten DokuWiki Password

If you have forgotten your DokuWiki password, it is possible to set a new password by clicking the Set New Password link on the Login page, then following the instructions. DokuWiki will email a new password to you. But what if the email never arrives?

The DokuWiki user names and passwords are stored in the file path-to-dokuwiki-installation/conf/users.auth.php in the following format:

login:passwordhash:Real Name:email:groups,comma,seperated

You cannot simply replace passwordhash with your new password, because the password needs to be hashed first. To hash your password, you can execute the same code that DokuWiki uses, with the interactive mode of PHP.

Enter directory path-to-dokuwiki-installation/inc:

$ cd path-to-dokuwiki-installation/inc

Start PHP interactive mode:

$ php -a

Import the file that contains the hashing code:

> require("PassHash.class.php");

Hash your new password:

> echo (new PassHash())->hash_smd5('newpassword') . PHP_EOL;

Copy the output of the last command, and replace the old passwordhash in path-to-dokuwiki-installation/conf/users.auth.php with the new one. Save the file.

Now you can login with your new password.

Tags: passwords tutorial dokuwiki php