Reply
New Member
Posts: 9
Registered: ‎05-05-2016

Re: Controller not letting me change admin password

Changing the password manually through the DB actually worked. Thanks! But still I can't change the password from the webGUI. Is there something in addition I need to do or just wait for an updated version to fix this?

Member
Posts: 246
Registered: ‎05-19-2015
Kudos: 454
Solutions: 2

Re: Controller not letting me change admin password

I just hit this too.   Also saw old usernames in the DB when I ran the lookup command.  

 

The MKPASSWD does not exist on a cloud Key so what's the best way to fix that?  Is the password change via UI a bug in 4.8 that is fixed in 5.0?  I have access to the beta but have not tried the password change int he UI and is it specific to the restore of a controller only?

 

@UBNT-MikeD and @UBNT-Brandon seems like something that's easy to test and seems in this thread it's after a controller restore.  Would be nice to get it fixed in the UI so we don't have to mess with the DB Man Happy

 

Also anyone know how to remove those 2 old user entries from old test sites?

Ubiquiti Employee
Posts: 9,201
Registered: ‎01-28-2013
Kudos: 15876
Solutions: 606
Contributions: 20

Re: Controller not letting me change admin password

On CloudKey you need to install 'whois' so that you have mkpasswd. 

apt-get update && apt-get install whois

You could remove these extra users with something like the following:

mongo --port 27117 ace --eval 'db.admin.remove( { "name" : "admin" } )'

Cheers,

Mike

New Member
Posts: 14
Registered: ‎07-22-2016
Kudos: 1

Re: Controller not letting me change admin password

[ Edited ]

@UBNT-MikeD wrote:

 

3. Update the salted hash in the database.

 

Run this command to update the salted hash that's stored in the database (replace the respective values with the ones you determined above):

 

mongo --port 27117 ace --eval 'db.admin.update( { "name" : "admin" }, { $set : { "x_shadow" : "$6$9Ter1EZ9$lSt6/tkoPguHqsDK0mXmUsZ1WE2qCM4m9AQ.x9/eVNJxws.hAxt2Pe8oA9TFB7LPBgzaHBcAfKFoLpRQlpBiX1" } } )'

(Note: If your username is 'admin' and you just want to set the password to 'password', you can simply copy/paste the above command and run it to do so.)

 

You're done! You can now log in with the new password that you set. 


 

NOTE - If you are doing this from Windows you will find out that the above doesn't parse correctly from the command line. To make it work, the single and double quotes must be changed.

 

Short version - Run this instead:

mongo --port 27117 ace --eval ^"db.admin.update^( { \^"name\^" : \^"admin\^" }, { $set : { \^"x_shadow\^" : \^"$6$9Ter1EZ9$lSt6/tkoPguHqsDK0mXmUsZ1WE2qCM4m9AQ.x9/eVNJxws.hAxt2Pe8oA9TFB7LPBgzaHBcAfKFoLpRQlpBiX1\^" } } ^)^"

 

Longer version - Each of the special characters for DOS  ^ < > | & ( ) "  needs a leading ^. Each ^" needs a leading \, and then you put ^" around the whole string. Those are not all of the rules, but they are enough to make this command work.

 

Thanks to http://www.daviddeley.com/autohotkey/parameters/parameters.htm#CPP for the excellent reference.

 

I can also verify that just pasting the original string posted INSIDE the mongo shell works just as well. Just run "mongo --port 27117 ace" to start the session and then you don't need to escape anything from the command line.

 

New Member
Posts: 1
Registered: ‎01-17-2017

Re: Controller not letting me change admin password

Hello:

 

Trying to reset the password, and I get this as a response when using the code above:

 

MongoDB shell version: 2.6.12

connecting to: 127.0.0.1:27117/ace

Cannot use commands write mode, degrading to compatibility mode

WriteResult({ "nMatched" : 0, "nUpserted" : 0 })

 

Any thoughts on how to proceed? If I change the "username" field in the supplied code to the confirmed username, I get the following:

 

MongoDB shell version: 2.6.12

connecting to: 127.0.0.1:27117/ace

2017-01-17T22:04:28.095-0500 SyntaxError: Unexpected token ILLEGAL

 

 

 

 

New Member
Posts: 1
Registered: ‎07-05-2017

Re: Controller not letting me change admin password

For Windows 10 This worked GREAT! Need the updated string with the ^ as described. Should be posted at the top of the list as a working FAQ
New Member
Posts: 26
Registered: ‎10-30-2017
Kudos: 1
Solutions: 1

Re: Controller not letting me change admin password

I have Unifi 5.5.20 installed on a raspberry pi.

 

When I connect to mongo this is what I am seeing:

 

root@rpiUnifi:~# mongo --port 27117
MongoDB shell version: 2.4.10
connecting to: 127.0.0.1:27117/test
Server has startup warnings:
Mon Oct 30 07:19:40.943 [initandlisten]
Mon Oct 30 07:19:40.943 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Mon Oct 30 07:19:40.943 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Mon Oct 30 07:19:40.943 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Mon Oct 30 07:19:40.943 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Mon Oct 30 07:19:40.943 [initandlisten]

but I am unable to list the users for the ace db:

 

> use ace
switched to db ace
> db.admin.find()
>

New to mongo, so Id prefer to not mess anything up, but I need to change the admin pwd from command line.

 

Please advise

New Member
Posts: 26
Registered: ‎10-30-2017
Kudos: 1
Solutions: 1

Re: Controller not letting me change admin password

This is not working for me on version 5.5.20. HEre is what I am seeing (nothing):

 

root@rpiUnifi:~# mongo --port 27117 ace --eval "db.admin.find().forEach(printjson);
>

>

 

New Member
Posts: 14
Registered: ‎07-22-2016
Kudos: 1

Re: Controller not letting me change admin password

 

@NautiCloud wrote:

...

but I am unable to list the users for the ace db:

 

> use ace
switched to db ace
> db.admin.find()
>

 



From the earlier messages, it appears that the command to list the usernames is: 

db.admin.find().forEach(printjson);

 

New Member
Posts: 14
Registered: ‎07-22-2016
Kudos: 1

Re: Controller not letting me change admin password

[ Edited ]

Are you actually being prompted for admin credentials in the Unifi interface? Or is it trying to run the new controller setup wizard?

New Member
Posts: 26
Registered: ‎10-30-2017
Kudos: 1
Solutions: 1

Re: Controller not letting me change admin password

Yes I have tried that. Here is the result:

 

root@rpiUnifi:~# mongo --port 27117
MongoDB shell version: 2.4.10
connecting to: 127.0.0.1:27117/test
Server has startup warnings:
Mon Oct 30 07:19:40.943 [initandlisten]
Mon Oct 30 07:19:40.943 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Mon Oct 30 07:19:40.943 [initandlisten] **       32 bit builds are limited to less than 2GB of data (or less with --journal).
Mon Oct 30 07:19:40.943 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.
Mon Oct 30 07:19:40.943 [initandlisten] **       See http://dochub.mongodb.org/core/32bit
Mon Oct 30 07:19:40.943 [initandlisten]
> use ace
switched to db ace
> db.admin.find().forEach(printjson);
>
>
New Member
Posts: 26
Registered: ‎10-30-2017
Kudos: 1
Solutions: 1

Re: Controller not letting me change admin password

Im trying to reset the admin pwd from command line access on the rpi. We have lost the password for both admin and superadmin users.
New Member
Posts: 14
Registered: ‎07-22-2016
Kudos: 1

Re: Controller not letting me change admin password

Maybe you should just move on with trying to update the password. Execute:

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

replacing "admin" with the names of known/suspected admin/superadmin users. If you get a hit, you will successfully reset the password to "password" using that command.
New Member
Posts: 26
Registered: ‎10-30-2017
Kudos: 1
Solutions: 1

Re: Controller not letting me change admin password

Regardless of which command I use, the result appears to be 'nothing'.

 

How can I be confident that I am actualy interacting with mongodb/the unifi db (ace)?

New Member
Posts: 14
Registered: ‎07-22-2016
Kudos: 1

Re: Controller not letting me change admin password

[ Edited ]

Looks like you really have no admin user. If you are running at least version 3.1.7, there is a solution. I pulled this from https://thinkofnetwork.wordpress.com/2014/10/23/unlock-lost-ubiquiti-unifi-controller/ and other pages as cited.

From https://help.ubnt.com/hc/en-us/articles/205202580-UniFi-What-is-the-system.properties-file-#advanced...
The system.properties file can/should contain a line such as:
super_admin.name=account_id_to_be_promoted

Change this line to a known user, or see what user is already listed. Assuming the user is "ubnt", you just need to create a new user named "ubnt".
You can create the user with the following 3 lines in the MongoDB Shell:
d = { “name” : “ubnt”, “lang” : “en_US”, “x_password” : “ubnt” , “time_created” : “”, “last_site_name” : “default”}
db.admin.insert ( d )
restart mongodb

The source page reference was written by a user that had already tried reinstalling Unifi, so the instructions to remove and re-add the package don't apply. You may or may not need to restart the Unifi service as well as the mongodb service (which should already have been restarted).

Hopefully adding a user and use of the the super_admin.name property for automatic promotion will be successful for you.

New Member
Posts: 26
Registered: ‎10-30-2017
Kudos: 1
Solutions: 1

Re: Controller not letting me change admin password

[ Edited ]

Ok,

So i Added the user 'ubnt' and modified the system.properties file to make this user the super_admin. 

 

Then I rebooted the machine.

 

The UI came back up and accepted the new credentials, but an alert appears for a websocket error and I am not seeing any elents in the UI. This is what I am seeing:

 

Capture.PNG

 

Clicking on the 'Click here link leads nowhere.

 

I am able to confirm that the user now exists in mongodb:

 

root@rpiUnifi:~# mongo --port 27117
MongoDB shell version: 2.4.10
connecting to: 127.0.0.1:27117/test
Server has startup warnings:
Tue Nov 7 08:22:21.568 [initandlisten]
Tue Nov 7 08:22:21.568 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.
Tue Nov 7 08:22:21.568 [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with --journal).
Tue Nov 7 08:22:21.568 [initandlisten] ** Note that journaling defaults to off for 32 bit and is currently off.
Tue Nov 7 08:22:21.568 [initandlisten] ** See http://dochub.mongodb.org/core/32bit
Tue Nov 7 08:22:21.568 [initandlisten]
> use ace
switched to db ace
> db.admin.find()
{ "_id" : ObjectId("5a01b1966ef23828246f55ff"), "last_site_name" : "", "x_shadow" : "$6$UXjH6zQC$sGKGw4/O0G/qa6sknF8fUHtAUYGSa4eal3qLsVk4sUszbQnjr8VVvf1Hbklhe4ClNZLidMYMVlnKyueLGKMSe0", "name" : "ubnt", "time_created" : "", "lang" : "en_US" }
>

 

Any ideas?

Member
Posts: 233
Registered: ‎08-22-2014
Kudos: 43
Solutions: 5

Re: Controller not letting me change admin password

I have an install doing the same thing... was this every resolve for the last poster?

 

when running db.admin.find()... it doesn't return anything

Backstory... had a CK updated to newest software 5.7.20 i believe... but web UI wouldn't load  (error pages).  downgraded back to 5.6.26, now web ui loads... but unable to login using known good credentials.   did the suggestions in this thread and ending up with same results as last poster... how should i proceed to be able to login?  Thanks!

Member
Posts: 233
Registered: ‎08-22-2014
Kudos: 43
Solutions: 5

Re: Controller not letting me change admin password

@UBNT-MikeD Any Ideas?

Emerging Member
Posts: 110
Registered: ‎07-09-2016
Kudos: 36
Solutions: 4

Re: Controller not letting me change admin password

[ Edited ]

Hi,

 

I am in the same boat here:

 

Backed up settings from Controler 5.7.23

Made fresh install of Controller 5.9.29 in new VM.

 

On setup Wizard, I uploaded the backup from 5.7.23 and hit "confirm"

 

After the 5.9.29 Controller came up again, no admin user was configured. In mongodb shell, database "ace", the command db.admin.count() returned a 0, so there are no users configured. This seems to be an error in the restore algorithms.

 

When I add the ubnt user directly into mongodb as suggested above, add the "super_admin.name=ubnt" in system.properties, and restart the unifi service I end up with the same 404 Error as mentioned above.

 

Regards

 Alex

 

New Member
Posts: 11
Registered: ‎04-26-2017
Kudos: 9

Re: Controller not letting me change admin password

ubiquiti sucks.  did a simple upgrade and now I'm locked out and can't get back in. I am hating this system today.

Reply