Forgotten password?! That’s easy right? 99.99% of service providers, apps or software out there carry an option to Reset Password. No biggie, so should Matrix, in some form or other. Right? Wrong. I use Element as the front-end for Matrix, both on the web and mobile. Although it provides an option of Forgot your password? but that’s only valid if the user has setup an email address. In this case though, there wasn’t any email tied to her account. So, a no go.
Next option was to directly edit Matrix database.
- Log on your server using SSH
- Generate hash for new password using (globally registered)
[email protected]:~# hash_password Password: Confirm password: $2b$12$2/C4k9xTve8W/Y0Q4psAF.5PA/QRm6ELlZxqO/067zYeUF/cImVC6
- A hash will be generated for the given password, copy the generated hash, somewhere safe.
- Open sqlite database (.db) located at
sudo -u matrix-synapse sqlite3 <DB_NAME>.db
- Once in database shell it’s a good idea to cross check the username before attempting to update password hash, you can get a list of all user by running the following user in database shell
SELECT * FROM users
sqlite> SELECT * FROM users; @admin:domain.tld|$2b$12$L0JkkZtsQ2B/Xo44Th8DXOjYdLCV10fJfPJH0Fo9.tddRHIuXJgW.|1624205912|1||0|||||0|0 @user:domain.tld|$2b$12$hIzHP0dJ./79/OQF9tQbcuTa6RTiwzibGMHRYUeud8SacqGw3Utja|1624287507|0||0|||||0|0 ..............
- Update the user’s password hash to one we generated earlier like so
UPDATE users SET password_hash='$2b$12$2/C4k9xTve8W/Y0Q4psAF.5PA/QRm6ELlZxqO/067zYeUF/cImVC6' WHERE name='@user:domain.tld';
- Quit from shell
.quitand test the updated password!