Ubiquiti Controller forgotten password and unable to login! Recently, I’ve ran into this weird issue where I could not log into a Ubiquiti Controller for the life of me. I knew the password was correct because I had used it before and I’ve even had it written down. I’ve wasted countless hours trying out derivatives of the password that I had, mixing up capital letters etc. without any success. I still don’t know for sure why this happened, my best guess would be that I’ve picked a password that did not pass Ubiquiti’s password complexity requirements and thus causing it to lock me out. I am however surprised that it went through in the first place. If anyone out there know exactly why this happens please let me know in the comments below. Anyhow, here is the resolution I’ve found during my research on how to reset your UniFi controller admin password.
How to Reset an Ubiquiti Controller Password?
Step 1 – Download Robomongo
This amazing program will allow you to access the configuration files of the UniFi Controller. Not only does it allow you to access the files but it also lets you to edit the config files. An older version may be harder to find now so I am adding a direct link to the download below. All credit goes to Robomongo developers, you may visit them at Robo 3T.
Please make sure that you install the Robomongo software on the same computer UniFi Controller is running. Running it on a remote PC will not let you authenticate to the UniFi database. Once you have the program installed and running, please continue to step two.
Step 2 – Edit Ubiquiti UniFi Config Files
Open up the Robomongo software & connect to the Ubiquiti Database. The screenshots below will show you how this is done, address should be “localhost” port should be “27117 “.
Navigate your way to the ace > admin file, there you will see the password in its encrypted format. Your password will be the longest line there in its encrypted form. Now we want to replace this password with another encrypted password, for that continue to step three.
Step 3 – Reset Ubiquiti Controller Administrator Password
We will head over to Quickhash and download the program to generate a new encrypted password to be used with our UniFi controller.
Once you have generated a new password in its encrypted form, copy that data and replace the password field “x_shadow“ in the Controller’s database as shown below.
Alternatively, you may also use the pre-created password that I have below and reset it to your own once logged in.
Encryption the password uses is : SHA-512 / crypt(3) / $6$ (just in case anyone is wondering)
Password:
ubuntu@1234
Encrypted Password:
$6$b98d16b2862d0445$oGME1OiFgQE/qamZFHw9Bh3t5BDgxHZoyebcb9QVThjI4Etd7X6imLVLwklBCIrQcHlffQVklKGrid6iTWnDt1
Step 4 – UniFi Controller Access & Login
Now you may try the login again using the password that you’ve set in step three. You should now be able to successfully sign in to the UniFi Controller. I would also restart the controller if it is already running just to double-check it is working properly.
If anyone has any idea why this issue occurs in the first place, I would appreciate it if you can shed some light on this problem in a comment below.
I hope this article was helpful for you in resolving the UniFi forgotten password issue. Thank You, for visiting & I hope you will stick around for more useful content.
Worked like a champ!!!
Just an FYI that on Windows I had to use the loopback adapter IP address to make this work (e.g. 120.0.0.1). Localhost didn’t work.
thank you jake for pointing that out!
Sorry, that should be 127.0.0.1. Typing too fast there for my own good.
Doesn’t work for me, tried it on two different PCs, two different controllers, no dice. It doesn’t show the results from query, I never see x_shadow
Thanks! Much appreciated given that quickhash.com is no longer live.
Hi Chris,
you should be able to do the same with https://quickhash-gui.org/screenshots/
Great, thanks a lot. Briefly and simply explained.
I did it with Roboter 3T, v1.2.
I only had a hard time to figure out, how to edit the value (right click -> edit document)!!!
Do you have it for mac?
Thank you very much works great
you are welcome!
You make it difficult to copy the encryption password!
Thanks, worked brilliantly for me
you are welcome! glad I could help.
I downloaded the latest version from Robomongo because I’m on a Mac.
When I open Collections under ACE I get an error.
“Failed to refresh ‘Collections’
List connections Failed ”
And I can’t find version 0.9.0-RC4 for Mac on their website.
Can you assist me?
Thnx in advance!
Nevermind.
I followed these instructions and this worked with the latest version for Mac.
Thnx anyway.
https://community.spiceworks.com/topic/2175763-hash-tool-to-reset-ubiquiti-unifi-controller-admin-password
After a successful password recovery using the above process, the Unifi Controller doesn’t start afterwards (If i close and try to restart it). Anyone else faced this?
i have not experienced this but try reinstalling the controller without reinstalling the one you have now, it should overwrite any missing files.
This saved me a lot of headache!!! Many thanks!!!
you are very welcome Joe!
Would be nice if I could copy your preconfigured password to paste it…
This is crazy, it worked! thank you very much
I cannot get past connections. I get an error message saying “Failed to refresh Collections”
This worked only by using your password.. ( which I see you cannot highlight and copy and paste in Chrome).
I used MongoDB compass to change it which worked like a charm.
Not sure why the password I generated from quickhash and the correct encryption and salt didn’t work?
Oh well thanks for the great document!
Perfect! Worked on the first try for V5.10.25! Thanx!
Very simple steps. Thanks
got it working thanks.
Hey.
I am trying to do the steps you mention above but, after i hit “ace” and i get the folders underneath, i try to open “Collection” Folder (or any other Folder for that extend), i get an Error Message.
This is this Error Message i get;
Error:
ListCollections failed: { ok: 0.0, errmsg: “no such cmd: listCollections”, bad cmd: { $query: { listCollections: 1, filter: {}, cursor: {} }, $readPreference: { mode: “secondaryPreferred” } } }
Worked perfect for me thanks so much! Saved alot of headaches.
@David
I right clicked on ace and started shell, ran this command
db.admin.find().forEach(printjson);
db.admin.update( { name: “admin” }, {$set: { x_shadow: “$6$9Ter1EZ9$lSt6/tkoPguHqsDK0mXmUsZ1WE2qCM4m9AQ.x9/eVNJxws.hAxt2Pe8oA9TFB7LPBgzaHBcAfKFoLpRQlpBiX1” } } );
This will set username : admin to password : “password”
Franchement, un Grand merci.
It worked. FYI there is a new Robomongo program version Robo 3T 1.3
great John, thank you for sharing!
Thank you for this… super helpfull
Thank You!!!!!
Worked after a reboot.
you are welcome!
I tried setting my password to “password” using these instructions but it didn’t work. I suspect that the Salt has changed – or the salt is based on the time_created value or the user name or something.
Any ideas?
How can you used to recover a Cloud Key ?
Thank you, worked like a charm.
You asked if we could shed some light on this problem. I can tell you what happened leading up to the problem.
Steps:
1. I changed one device from cabled network to wifi only. So the device uses POE , but not the network over the cable,
2. I requested to update the devices and the controller; browser stayed logged in (kind of weird, I expected that I would get a login request again),
3. Some one else logged in on my computer (not logging me out),
4. Power off,
5. A few hours later I powered the computer up and wanted to continue working on the network.
Result:
Could not log in anymore.
Kind regards
If you have root CLI access to your Linux system this works as well based on the article.
root@Ubiquity1:~# mongo –port 27117
MongoDB shell version v3.4.21
connecting to: mongodb://127.0.0.1:27117/
MongoDB server version: 3.4.21
Server has startup warnings:
2020-03-25T18:13:38.040+0000 I STORAGE [initandlisten]
2020-03-25T18:13:38.040+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2020-03-25T18:13:38.040+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2020-03-25T18:13:41.003+0000 I CONTROL [initandlisten]
2020-03-25T18:13:41.005+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2020-03-25T18:13:41.005+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2020-03-25T18:13:41.005+0000 I CONTROL [initandlisten]
2020-03-25T18:13:41.007+0000 I CONTROL [initandlisten]
2020-03-25T18:13:41.009+0000 I CONTROL [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 62576 processes, 524288 files. Number of processes should be at least 262144 : 0.5 times number of files.
> use ace
switched to db ace
> db.admin.update( { name: “admin” }, {$set: { x_shadow: “$6$b98d16b2862d0445$oGME1OiFgQE/qamZFHw9Bh3t5BDgxHZoyebcb9QVThjI4Etd7X6imLVLwklBCIrQcHlffQVklKGrid6iTWnDt1” } } )
WriteResult({ “nMatched” : 1, “nUpserted” : 0, “nModified” : 1 })
Pull up webpage @ https://IP:8443 and use username: admin and password: ubuntu@1234
**Remember to change the password once you aret in again**
I’m getting
WriteResult({ “nMatched” : 0, “nUpserted” : 0, “nModified” : 0 })
when trying both John’s and sba’s commands in ubuntu. I wish I could copy the text from this site but I’m fairly certain I did not make a typo. I actually copied the has from the original post (was copyable) and also tried shortening it to Jon’s version. I don’t get errors in mongo but the password doesn’t work.
Your admin user name may not be “admin” then. Run this mongo command:
>db.admin.find().forEach(printjson);
It will show you the username.
Hi,
I tried both (Johns & sda’s) versions too getting:
WriteResult({“nMatched” : 0, “nUpserted” : 0, “nModified” :0 })
When I try db.admin.find().forEach(printjson);
I get no output?!
You guys have an idea?
Great article I got things to work using the steps and the values provided in the example.
Two things I want to point out:
1) when copying (using windows) the copy button had spaces leading and trailing spaces. Be careful as these caused me problems. Leaving the spaces out worked.
2) i was unable to recreate a hash for ubuntu@1234 that matches the example (again I’m on windows) using QuickHash. Are there settings for setting the algorithm to SHA-512 / crypt(3) / $6$ as referenced in the article?
Any insight to this would be appreciated.
Thanks. Everything worked great except the output from QuickHash.
I ended up using your encrypted password and changing it afterwards.
MANY MANY THANKS – THIS WORKED!
DONT USE QUICKHASH IT WONT GIVE YOU THE RIGHT HASH
Copy hash will work
Hi Rasd,
thank you for the tip!
Thanks for this, really helped with an ex-employee changing the password and not updating the documentation!
I can confirm it worked on UniFi Network Application 7.4.156 on a Windows server.
Just check for spaces when copying the password 🙂