explaingit

pueblokc/unifi-protect-recovery

12PythonAudience · ops devopsComplexity · 2/5Setup · easy

TLDR

Extracts per-device recovery codes from your UniFi Protect NVR's backup file over local SSH and exports them to a CSV spreadsheet, so you are never locked out after a factory reset.

Mindmap

mindmap
  root((unifi-protect-recovery))
    What It Does
      SSH to NVR
      Download backup
      Extract codes
      Export CSV
    Interfaces
      Windows GUI
      Python GUI
      Command line
    Output Fields
      Device name
      MAC address
      Recovery code
    Use Cases
      Pre-reset backup
      Device re-adoption
      Security docs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Run the tool before a planned device reset to export all UniFi Protect recovery codes to a CSV before you need them

USE CASE 2

Recover adoption credentials after discovering a device needs its recovery code and you never saved it

USE CASE 3

Use the CLI version on Mac or Linux to export recovery codes to JSON for integration with a password manager

USE CASE 4

Store the exported CSV in a secure location as part of a UniFi network disaster-recovery documentation checklist

Tech stack

PythonPowerShellSSH

Getting it running

Difficulty · easy Time to first run · 5min

Requires SSH access to your UniFi Protect NVR and the NVR's admin credentials.

No license information was provided in the explanation.

In plain English

UniFi Protect is a video surveillance system made by Ubiquiti that runs on a dedicated device called an NVR (network video recorder). Every camera, bridge, light, speaker, and other device in that system has something called a recovery code: a per-device password that lives inside the NVR's nightly backup file. Most people never think about it until the moment a device needs a factory reset or they are moving to a new controller, at which point UniFi asks for the code and there is no obvious way to get it. Without the code, the device may not be adoptable again. This tool exists to solve that problem before it becomes urgent. It connects to your NVR over an encrypted SSH connection, finds the most recent backup file the NVR created overnight, downloads it to your computer, and extracts the recovery code for every device into a single CSV spreadsheet. The whole process stays on your local network. Nothing is sent to any cloud service. There are three ways to run it depending on what you have available. Windows users can double-click a batch file launcher that runs either a PowerShell-based graphical interface (no Python required) or a Python-based graphical interface. Both show a simple form where you type in your NVR's IP address, username, and password, then click two buttons. Mac and Linux users can run the Python GUI directly or use the command-line version, which accepts a backup file path and exports to text, CSV, or JSON. The output CSV lists each device by type, name, model, MAC address, IP address, and recovery code. The README is clear that this file is effectively a password list and should be stored somewhere secure, not committed to version control or shared publicly. The repository's built-in ignore rules already block CSV files from being accidentally committed. The tool was built by KCCS and is not affiliated with or endorsed by Ubiquiti.

Copy-paste prompts

Prompt 1
I need to factory reset a UniFi camera but don't have its recovery code. Using unifi-protect-recovery, walk me through connecting to my NVR, downloading the backup, and extracting the code.
Prompt 2
Help me run unifi-protect-recovery on a Mac to export all device recovery codes from my UniFi Protect NVR to a CSV file I can store in my password manager.
Prompt 3
Using the unifi-protect-recovery CLI, write a shell script that extracts all recovery codes and saves them in JSON format for import into a secrets manager.
Prompt 4
Explain what a UniFi Protect recovery code is, why unifi-protect-recovery retrieves it from the NVR backup rather than the UI, and when I would need it.
Open on GitHub → Explain another repo

← pueblokc on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.