Page 1 of 1

Reseting admin password

Posted: Sun Apr 19, 2020 8:48 pm
by Piata
I have access to SFTP and the DB. What's the easiest way to reset my password?

I tried encrypting a new password with bcrypt and dropping it into the DB but that doesn't appear to work.

It's surprisingly hard to find any recent information about this subject.

Re: Reseting admin password

Posted: Mon Apr 20, 2020 3:49 am
by erAck
Try if this works better:

Code: Select all

php -r 'echo password_hash("YourPassword", PASSWORD_BCRYPT) . "\n";'
and ensure the table's hashtype field has value 2 (old 1 would be sha1 that would have to be converted).

Re: Reseting admin password

Posted: Sun Apr 26, 2020 4:30 pm
by Piata
Thanks for the reply! I ended up creating a php file with the following:

Code: Select all

<?php
    $username = "admin-username";
    $password = "newpassword";
    include 'serendipity_config.inc.php';
    echo serendipity_db_query("UPDATE {$serendipity['dbPrefix']}authors SET password = '" . serendipity_hash($password) . "', hashtype=2 WHERE username = '" . serendipity_db_escape_string($username) . "'");
    echo "Password changed.";
?>
But I assume your solution would also work and might have been faster.

Re: Reseting admin password

Posted: Sun Apr 26, 2020 7:37 pm
by erAck
Nice automated solution. The essential part is that serendipity_hash() calls password_hash($string, PASSWORD_BCRYPT).

Now why did I find that now in my snippets collection as well, it must had been published somewhere and I didn't think of.

Anyway, glad it works.