bajsicki.com/public/posts/misskey-resetting-admin-password/index.html

179 lines
4.6 KiB
HTML
Raw Normal View History

2024-09-26 14:32:13 +02:00
<!DOCTYPE html>
<html lang="en-us"><head><script src="/livereload.js?mindelay=10&amp;v=2&amp;port=1313&amp;path=livereload" data-no-instant defer></script>
<title>MissKey: Resetting Admin Password - phil@bajsicki:~$</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="description"
content="So recently I had the need to reset the admin password in MissKey.
Alas, there was no recovery email configured, nor other users on the instance, so I needed to do some digging in the database. ">
<link rel="canonical" href="http://localhost:1313/posts/misskey-resetting-admin-password/" />
<link rel="icon" href="http://localhost:1313/images/logo_w.png" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/modern-normalize/1.1.0/modern-normalize.min.css" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="preload" as="style"
href="https://fonts.googleapis.com/css?family=Noto+Serif+SC|Noto+Emoji&display=swap" />
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Noto+Serif+SC|Noto+Emoji&display=swap"
media="print" onload="this.media='all'" />
<noscript>
<link rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Noto+Serif+SC&display=swap" />
</noscript>
<link rel="stylesheet" href="/css/hugo-tufte.min.css">
<link rel="stylesheet" href="/css/hugo-tufte-options.min.css">
<link rel="stylesheet" href="/css/hugo-tufte-override.css">
</head>
<body>
<article id="main">
<header class="brand">
<h1>phil@bajsicki:~$</h1>
<p class="subtitle"></p>
<nav class="menu">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/posts/">Posts</a></li>
</ul>
</nav>
<hr />
</header>
<section>
2024-09-27 15:29:50 +02:00
<h1 class="content-title">MissKey: Resetting Admin Password</h1><span class="content-meta"><p class="date">2023-08-11</p><span>1 min read&nbsp;</span><a href="http://localhost:1313/tags/misskey">misskey</a>&nbsp;<a href="http://localhost:1313/tags/admin">admin</a>&nbsp;<a href="http://localhost:1313/tags/postgres">postgres</a>&nbsp;<a href="http://localhost:1313/categories/tech">@tech</a>&nbsp;</span></section>
2024-09-26 14:32:13 +02:00
<section><p>So recently I had the need to reset the admin password in <a href="https://github.com/misskey-dev/misskey/">MissKey</a>.</p>
<p>Alas, there was no recovery email configured, nor other users on the instance, so I needed to do some digging in the database.</p>
<p>So here is the short of it.</p>
<ol>
<li>Log in with your misskey user into postgres (assuming that&rsquo;s what you&rsquo;re running MissKey on).</li>
<li>Connect to the database.</li>
<li><code>select * from &quot;user&quot; where &quot;isAdmin&quot; = true;</code></li>
<li>Grab the <code>userId</code> for the user you&rsquo;re resetting the password for.</li>
<li><code>select * from user_profile where &quot;userId&quot; = 'your-userId';</code> to confirm that you&rsquo;re getting the right info.</li>
<li>Get the hashed password with <code>bcrypt</code>, such as:
<code>python -c 'import bcrypt; print(bcrypt.hashpw(&quot;new-password&quot;, bcrypt.gensalt(log_rounds=10)))'</code></li>
<li><code>UPDATE user_profile SET password = 'hashed-password' WHERE &quot;userId&quot; = 'your-userId';</code></li>
</ol>
<p>Notes:</p>
<ul>
<li>Step 6 requires that you have python-bcrypt installed, and uses that library to do its thing.</li>
<li>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.</li>
</ul>
<p>And&hellip; done.</p>
<p><!-- raw HTML omitted --><a href="https://my.fsf.org/join">Join the FSF.</a><!-- raw HTML omitted --></p></section>
<section><footer class="page-footer">
<hr />
<div class="previous-post" style="display:inline-block;">
<a class="link-reverse" href="http://localhost:1313/posts/my-favorite-factorio-mods/?ref=footer">« My favorite Factorio mods</a>
</div>
<div class="next-post", style="display:inline-block;float:right;">
<a class="link-reverse" href="http://localhost:1313/posts/a-new-look/?ref=footer">A new look: ox-tufte »</a>
</div>
<ul class="page-footer-menu">
</ul>
<div class="copyright">
<p>
©2024 Phil Bajsicki
</p>
</div>
</footer>
</section>
<section><nav class="menu">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about/">About</a></li>
<li><a href="/posts/">Posts</a></li>
</ul>
</nav>
</section>
</article>
</body>
</html>