Reset admin password on UniFi controller to access wireless configuration.

unifi controller

UniFi controller – login form

Install whois package to use overfeatured front end to crypt(3).

$ sudo apt-get install whois

Generate new password using random salt.

$ printf "mypassword" | mkpasswd --stdin --method=sha-512
$6$LvF7R7Q3qo$bXFAWhbscrQ1rxYXF.Ut.iJ5I.59HBx8mpJnF3AayklAgX/izmh/Q16jG4aSlbI557QbwxnnV8LfkyqC0cZhc/

Use ssh to access remote machine.

$ ssh unifi.example.org

Connect to the local MongoDB instance.

$ mongo --port 27117 --shell --quiet

List databases.

> show dbs
ace       0.001GB
ace_stat  0.000GB
local     0.000GB

Switch the current database to ace.

> use ace
switched to db ace

List admins.

> db.admin.find()
{ "_id" : ObjectId("5a4552a24f0c66c01a730277"), "x_shadow" : "$6$IeSrq0LS$14mN.UZ5yh2wXspXr.Ee6flD5vg5wRmMqgmnX9DL79u2o/9Z9EaBkLx2Di8OG.Gb0wq6Vy4wnEpg.7Istdfuu1", "name" : "root", "email" : "milosz@sleeplessbeastie.eu", "time_created" : NumberLong(1514492578), "last_site_name" : "default" }

Replace value of the x_shadow field with the previously generated password.

> db.admin.update({"_id":ObjectId("5a4552a24f0c66c01a730277")},{$set: {"x_shadow" : "$6$LvF7R7Q3qo$bXFAWhbscrQ1rxYXF.Ut.iJ5I.59HBx8mpJnF3AayklAgX/izmh/Q16jG4aSlbI557QbwxnnV8LfkyqC0cZhc/"}})
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })

Verify that by some mistake you have not replaced whole document.

> db.admin.find({"name":"root"})
{ "_id" : ObjectId("5a4552a24f0c66c01a730277"), "x_shadow" : "$6$LvF7R7Q3qo$bXFAWhbscrQ1rxYXF.Ut.iJ5I.59HBx8mpJnF3AayklAgX/izmh/Q16jG4aSlbI557QbwxnnV8LfkyqC0cZhc/", "name" : "root", "email" : "milosz@sleeplessbeastie.eu", "time_created" : NumberLong(1514492578), "last_site_name" : "default" }

Use new password to access UniFi controller.

ko-fi