Skip to content

Instantly share code, notes, and snippets.

@kiwimato
Last active February 11, 2025 23:18
Show Gist options
  • Save kiwimato/07462b0fc38fe987d2413adc6dc219af to your computer and use it in GitHub Desktop.
Save kiwimato/07462b0fc38fe987d2413adc6dc219af to your computer and use it in GitHub Desktop.
Unifi Ubiquity restore old camera settings
sshpass -p ubnt ssh [email protected] -o StrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null "wget http://192.168.123.145/persistent.tar.gz -O /tmp/pe.tar.gz;tar xzvf /tmp/pe.tar.gz -C /;echo -e 'bambamYourNewPazzdHere\bambamYourNewPazzdHere\n' |passwd "
# break down for easier reading - I didn't test if it works with the line breaks:
sshpass -p ubnt ssh [email protected] -o StrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null "\
wget http://192.168.123.145/persistent.tar.gz -O /tmp/pe.tar.gz;\
tar xzvf /tmp/pe.tar.gz -C /;\
echo -e 'bambamYourNewPazzdHere\bambamYourNewPazzdHere\n' |passwd "
@kiwimato
Copy link
Author

kiwimato commented Feb 11, 2025

I have a an old Unifi Camera and the persistent memory is not working anymore, so whenever the power goes out, the camera resets to factory settings.
However, it works just fine if i configure it manually.

This has been tested with UVC Dome on v4.23.8 and Unifi NVR.

I wrote a little script that can help restore the configuration automatically. Of course, make sure to replace the dummy IPs mentioned below with your current ones.

  • UVC Camera IP: 192.168.123.138

  • Unifi NVR: 192.168.123.145

    • First configure the camera manually in the UI by accessing it's URL and connect with ubnt/ubnt and adopt it into the NVR
    • SSH into the camera and create a tarball with the necessary config:
      tar czvf /tmp/persistent.tar.gz /etc/persistent/ /tmp/system.cfg
    • Download this file using sftp or some other tool and store it somewhere, I store it in NVR in /usr/share/nvr-webui/www
    • Install sshpass on the NVR or wherever you store the file and run this in crontab:
        sshpass -p ubnt ssh [email protected] -o StrictHostKeyChecking=no -oUserKnownHostsFile=/dev/null  "wget http://192.168.123.145/persistent.tar.gz -O /tmp/pe.tar.gz;tar xzvf /tmp/pe.tar.gz -C /;echo -e 'bambamYourNewPazzdHere\bambamYourNewPazzdHere\n' |passwd "
      
    • Make sure to replace the bambamYourNewPazzdHere with your password, because this will be the new camera password. I used the adoption token, because that's what the other cameras use.
    • Voila! You should see the camera again in the NVR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment