blog how-to
Unifi Ubiquiti Logo

Resetting a Unifi Controller’s admin password

If you use Unifi gear, you know that it can proliferate quite fast. Couple that with cameras, a second network for cameras, and you have a growing need for more Unifi controllers to manage devices. The best approach is to, uhm, unifi controllers into a cloud-based setup – but you can’t always do that. When controllers get isolated on networks, you may find that you’ve lost the administrator password for one. Here’s how you can reset it so long as you have root shell access to the machine running your controller.

The first step is to connect to the controller’s network and ssh to that server. My example will presume you’re running a Linux computer with the Unifi controller installed and also running.

Once you’ve ssh’d in , Gather some info:
1. Run mongo to see you have the client if not, you may need to install it.

2. Determine what your username is with this command. Look for the output line labelled “name” :

mongo --port 27117 ace --eval "db.admin.find().forEach(printjson);"

(in my example it’s administrator)

Now, you’re ready to reset the password. I should note also, this process is going to overwrite your existing password. Be careful. While still logged into the shell as root, run these commands.

1. Connect to the database server:

mongo -port 27117

2. Use the database:

use ace

3. Reset the password:

db.admin.update( { name: "administrator" }, {$set: { x_shadow: "$6$9Ter1EZ9$lSt6/tkoPguHqsDK0mXmUsZ1WE2qCM4m9AQ.x9/eVNJxws.hAxt2Pe8oA9TFB7LPBgzaHBcAfKFoLpRQlpBiX1" } } );

4. Then exit the mongodb prompt >

exit

Now your controller admin’s password will be reset to password.

I’ve verified this on controller version 5.6.26, Linux version. Your mileage will vary as versions change, but this might get you started.