Linux Unifi Controller Change Admin password

Password reset procedure for Linux:

1. Find out your username.
If you don’t know it any more and it’s not ‘admin’, run this command to get all Admin users on the controller:


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

You should get a result like this:

MongoDB shell version: 2.4.10
connecting to: 127.0.0.1:27117/ace
{
"_id" : ObjectId("56e178af97f2d0511ce3abea"),
"email" : "admin@admin",
"last_site_name" : "default",
"name" : "admin",
"time_created" : NumberLong(1457617071),
"x_shadow" : "$6$O6Uuq5Vww6zNxd$06bwBj5v4e0omEZ97qRbiaZbOi75o.r 5M4ympQYmY5FP8C.0QGenCIkymiK/YkWoDDfw1YcS42LYSFvPH gP7U0"
}
 

Note the “name” field above. It contains the username (“admin” in this example).

2. Generate a new password.
Run this command to get a new salted hash:

  

mkpasswd -m sha-512
Password: <enter your new password>
$6$9Ter1EZ9$lSt6/tkoPguHqsDK0mXmUsZ1WE2qCM4m9AQ.x9 /eVNJxws.hAxt2Pe8oA9TFB7LPBgzaHBcAfKFoLpRQlpBiX1
 

The long $6$9Ter… string is your new salted password hash. (The example above uses ‘password’, so if you just want to reset your account to ‘password’, you can copy/paste it directly from the example.)

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.x 9/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.

Bad Behavior has blocked 745 access attempts in the last 7 days.