Lost password on local install with no mail config

welp…

I lost my password on my localhost installation of ghost2.
and I can’t remember it.

surely, I wanna reset it somehow.

when I click to retrieve it via email I get this warning:

Failed to send email. Reason: connect ETIMEDOUT 108.177.126.27:25.

@diomed You have to configure the SMTP/mail settings for restoring your password, you can find more info through the official docs. Once you’ve done that, restart Ghost and you should be able to reset your password.

I’m wasting bunch of time trying to set this up - unsuccessfully.
Was hoping this would be easier, but no.

Is there any way I could go into database and just change password?

You should be able to insert a new password into the database - however as we don’t store plain text passwords in the database you’ll have to hash it first.

Looking at https://github.com/TryGhost/Ghost/blob/master/core/server/lib/security/password.js

You should be able to create a little script like:

// make-password.js
require('/path/to/ghost/core/server/lib/security/password')
  .hash(process.argv[2])
  .then(console.log);
node make-password.js "<your-new-password>"

You should then be able to insert that value in the the password column of the users table.

Let me know if that helps :slight_smile:

3 Likes

sorry for my lack of understanding, but this little script, where should I write it, exactly?

actually, could I just use some MD5 hash generator and then put result in my .json under content/data and it would be okay, right?

No worries.

To be clear this is a hack.

You can put the script anywhere - maybe your home directory would be a good choice :slight_smile:
You just need to make sure the /path/to/ghost/ is correct.

We don’t use md5 to hash our passwords as it is too fast, we use the bcrypt algorithm, as you can see in the file I linked above (https://github.com/TryGhost/Ghost/blob/master/core/server/lib/security/password.js).

You must also put the result into the database, not in a json file!

Hope this helps :slight_smile:

how do I edit ghost database?
I’m on windows and when I open it with text editor it’s just series of numbers and letters.
I need some database editor, I guess.

If you’re not sure about how to edit your database I would advise you to follow @Tony’s advice above and set up your mail setting according to the ghost docs. Here’s the link again https://docs.ghost.org/docs/mail-config :slight_smile:

I downloaded DB Browser for SQLite, imported Ghost’s database, then looked for users.
replaced hashed password and all is good now.

Thanks for help
Screenshot_20

1 Like

Awesome - nice work :smile:

Glad I could help!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.