40 lines
1.5 KiB
Markdown
40 lines
1.5 KiB
Markdown
+++
|
|
title = "MissKey: Resetting Admin Password"
|
|
publishDate = 2023-08-11T00:00:00+02:00
|
|
lastmod = 2024-11-18T20:14:42+01:00
|
|
tags = ["misskey", "admin", "postgres"]
|
|
categories = ["tech"]
|
|
draft = false
|
|
meta = true
|
|
type = "list"
|
|
[menu]
|
|
[menu.posts]
|
|
weight = 3002
|
|
identifier = "misskey-resetting-admin-password"
|
|
+++
|
|
|
|
So recently I had the need to reset the admin password in [MissKey](https://github.com/misskey-dev/misskey/).
|
|
|
|
Alas, there was no recovery email configured, nor other users on the instance, so I needed to do some digging in the database.
|
|
|
|
<!--more-->
|
|
|
|
So here is the short of it.
|
|
|
|
1. Log in with your misskey user into postgres (assuming that's what you're running MissKey on).
|
|
2. Connect to the database.
|
|
3. `select * from "user" where "isAdmin" = true;`
|
|
4. Grab the `userId` for the user you're resetting the password for.
|
|
5. `select * from user_profile where "userId" = 'your-userId';` to confirm that you're getting the right info.
|
|
6. Get the hashed password with `bcrypt`, such as:
|
|
`python -c 'import bcrypt; print(bcrypt.hashpw("new-password", bcrypt.gensalt(log_rounds=10)))'`
|
|
7. `UPDATE user_profile SET password = 'hashed-password' WHERE "userId" = 'your-userId';`
|
|
|
|
Notes:
|
|
|
|
- Step 6 requires that you have python-bcrypt installed, and uses that library to do its thing.
|
|
- There is a difference between single quotes, double quotes, and lowercase/ capitals. This is a quirk of psql, so make sure you get those right.
|
|
|
|
And... done.
|
|
|
|
<span class="underline">[Join the FSF.](https://my.fsf.org/join)</span>
|