[Freedombox-discuss] Forgot admin password

Paul van der Vlis paul at vandervlis.nl
Wed Apr 1 23:21:26 BST 2020

Op 01-04-2020 om 12:26 schreef Geert Stappers:
> On Wed, Apr 01, 2020 at 11:53:52AM +0200, Paul van der Vlis wrote:
>> Hello,
>> A customer changed the admin-password and forgot the new password.
>> I can come into his Freedombox as root using SSH,
>> but did not found a way to change the password.
>> I guess I will do a reinstall now,
>> but I would like to know the way to reset the password.
> ML archive has some clue.  Websearch on me + password reset.
> I guess it was about a year ago.
> Please report back.   En dat mag in het nederlands.

Let's do it in English.

Changing the password did work.

First change the LDAP password (this is one line):
echo -n '<password>' | /usr/share/plinth/actions/users set-user-password

Then you need to create a little script "change_plinth_password.py":

from django.contrib.auth.hashers import PBKDF2PasswordHasher as Hasher
import subprocess
import sys

hasher = Hasher()
salt = hasher.salt()
encoded_password = hasher.encode(sys.argv[2], salt)
query = 'UPDATE auth_user SET password="{}" WHERE
username="{}"'.format(encoded_password, sys.argv[1])
subprocess.run(['sqlite3', '/var/lib/plinth/plinth.sqlite3'],
check=True, input=query.encode())

Executing the script gave an error, I needed first to install the
package "sqlite3":
apt install sqlite3

Then run the script:
python3 change_plinth_password.py <username> <password>


Paul van der Vlis Linux systeembeheer Groningen

More information about the Freedombox-discuss mailing list