Skip to content

Instantly share code, notes, and snippets.

@AmazingTurtle
AmazingTurtle / how-to-restore.md
Last active July 11, 2024 14:39
restore access to unifi controller

Restore access to a unifi controller

When you are unable to login to the unifi controller or forgot admin password, you can restore access using SSH and manipulating mongodb directly.

Warning

Do not uninstall unifi controller - most of the data is not stored in mongodb. In case you thought a mongodb backup would be sufficient, you may have fucked up already, just like me. However I managed to write this "tutorial" for anyone to not run into the same trap.

Apparently this guide no longer works with recent unifi controller versions (starting nov/dec 2022). Since I no longer use unifi hardware in my home system, I can not update the guide myself. In case you've gotten here to recover your data, you're likely doomed. But giving it a try won't hurt anyway, therefore: good luck.

#!/usr/bin/env python3.7
import sys
import tty
import termios
import subprocess
import re
from pathlib import Path, PurePath
def getch():