Reseting admin password

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
Piata
Regular
Posts: 7
Joined: Tue Sep 20, 2005 7:37 pm

Reseting admin password

Post by Piata » Sun Apr 19, 2020 8:48 pm

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.

User avatar
erAck
Regular
Posts: 138
Joined: Mon Feb 16, 2015 1:20 am

Re: Reseting admin password

Post by erAck » Mon Apr 20, 2020 3:49 am

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).

Piata
Regular
Posts: 7
Joined: Tue Sep 20, 2005 7:37 pm

Re: Reseting admin password

Post by Piata » Sun Apr 26, 2020 4:30 pm

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.

User avatar
erAck
Regular
Posts: 138
Joined: Mon Feb 16, 2015 1:20 am

Re: Reseting admin password

Post by erAck » Sun Apr 26, 2020 7:37 pm

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.

Post Reply