{"id":4324,"date":"2021-12-15T17:14:28","date_gmt":"2021-12-15T23:14:28","guid":{"rendered":"https:\/\/www.incredigeek.com\/home\/?p=4324"},"modified":"2021-12-15T17:24:12","modified_gmt":"2021-12-15T23:24:12","slug":"change-unifi-user-password-from-command-line","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/change-unifi-user-password-from-command-line\/","title":{"rendered":"Change UniFi User Password from Command Line"},"content":{"rendered":"\n<ol class=\"wp-block-list\"><li>SSH into the UniFi server<\/li><li>Connect to MongoDB<\/li><li>Find user ObjectId<\/li><li>Update user info with new Password<\/li><\/ol>\n\n\n\n<p>You will need a hash of the password to put into the database.  We don&#8217;t cover that in this post.  You could copy the password from a different user account or use a different UniFi instance to change the password and then check the DB to find the hash.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">SSH into the UniFi Server<\/h2>\n\n\n\n<pre class=\"wp-block-preformatted\">ssh unifiadmin@unifiserver<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Connect to MongoDB<\/h2>\n\n\n\n<p>Connect to Mongo by typing in the following.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">mongo -port 27117<\/pre>\n\n\n\n<p>Then select the ace database by typing<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">use ace<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Find user ObjectId <\/h2>\n\n\n\n<p>The admins are in the admin collection\/table.  Use the following command to list all the users and their name, email, and password hash.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">db.admin.find({ }, { name:\"\" , email : \"\", \"x_shadow\" : \"\" })<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Update user info with new Password<\/h2>\n\n\n\n<p>The following looks complex.  Fortunately though you should be able to copy and paste.  You should only need to change the <br> &#8211; ObjectId to your User Id<br> &#8211; Password Hash to your password hash<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">db.admin.update({\"_id\" : ObjectId(\"223abc5489de0a93be758493\")}, {$set: { \"x_shadow\" : \"$6$nwpi7.q2$OuD9\/UZGZt5cD739Dt7j8Gb1uPtfU99p0DeDSurSNBZVizieUrFVFbRufiZMgOk2IaaDZN9BVmL9yUwQ2mC8f.\"}});<\/pre>\n\n\n\n<p>Note: The hash above is password.  Not recommended for use.<\/p>\n\n\n\n<p>You should receive a confirmation that it succeeded. Test the new password by logging into the UniFi Controller.  <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>For more MongoDB commands, check out this <a href=\"https:\/\/www.incredigeek.com\/home\/basic-mongodb-commands\/\" data-type=\"post\" data-id=\"1749\">post<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SSH into the UniFi server Connect to MongoDB Find user ObjectId Update user info with new Password You will need a hash of the password to put into the database. We don&#8217;t cover that in this post. You could copy &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/change-unifi-user-password-from-command-line\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[129,979],"tags":[8,371,200,11,132,974,188],"class_list":["post-4324","post","type-post","status-publish","format-standard","hentry","category-ubiquiti","category-unifi","tag-command-line-2","tag-mongo","tag-password","tag-reset","tag-ubnt","tag-ui","tag-unifi"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=4324"}],"version-history":[{"count":5,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4324\/revisions"}],"predecessor-version":[{"id":4330,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/4324\/revisions\/4330"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=4324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=4324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=4324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}