{"id":1789,"date":"2023-03-02T20:49:22","date_gmt":"2023-03-03T01:49:22","guid":{"rendered":"https:\/\/enterpriseadmins.org\/blog\/?p=1789"},"modified":"2023-03-02T20:49:22","modified_gmt":"2023-03-03T01:49:22","slug":"keep-it-secure-automate-skyline-collector-admin-password-changes","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/keep-it-secure-automate-skyline-collector-admin-password-changes\/","title":{"rendered":"Keep it secure: Automate Skyline Collector admin password changes"},"content":{"rendered":"\n<p>Too frequently I login to my Skyline Collector and am immediately required to change the password.  Follow along with me as I explain how I figured out how to use automation to reduce the frustration of this process.<\/p>\n\n\n\n<p>The Skyline Collector admin password will expire every 90 days.  Because it&#8217;s not necessary to login to the collector frequently, it is common that when I do login, I&#8217;m force to immediately change the password.  I began looking for an option to change this password programmatically, thus enabling the ability to schedule a task that would update the password before it expired, preferably every 30 days or so.  That way when I go to login the password doesn&#8217;t need to be immediately changed and I can move along with my task.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Finding the API method<\/h3>\n\n\n\n<p>To find the API method being used, I opened the developer tools in my browser, switched to the Network tab, then began watching the monitor while I changed the admin password for my Skyline Collector.  When I clicked the button to change password, the &#8216;request URL&#8217; on the Headers tab shows that the method called is <code>\/api\/v1\/auth\/update?auto=false<\/code> (picture below):<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-6.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"619\" src=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-6-1024x619.png\" alt=\"\" class=\"wp-image-1790\" srcset=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-6-1024x619.png 1024w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-6-300x181.png 300w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-6-768x465.png 768w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-6.png 1521w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>On the &#8216;Payload&#8217; tab I can see the JSON body that was posted to the <code>\/api\/v1\/auth\/update<\/code> method in the request URL (from the above screenshot).  The request body looks like this:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"634\" src=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-7-1024x634.png\" alt=\"\" class=\"wp-image-1791\" srcset=\"https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-7-1024x634.png 1024w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-7-300x186.png 300w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-7-768x475.png 768w, https:\/\/enterpriseadmins.org\/blog\/wp-content\/uploads\/2023\/02\/image-7.png 1516w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Write a Script to Automate the Password Change<\/h3>\n\n\n\n<p>Knowing the API method called as well as the details of the payload gives us the details that we need to write some code.  We could use any tool\/language, but having a prefernce towards PowerShell I chose that path.  The below example does just that &#8212; and the results showed <code>Password updated successfully<\/code>!<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$serverName = 'h027-skyline-01.lab.enterpriseadmins.org' # variable for Skyline Collector name\/IP.\n$changePassBody = @{'username'='admin'; 'oldPassword'='VMware1!'; 'newPassword'='VMware2!'} # JSON payload\n# Following line will use variables above to POST the request\nInvoke-RestMethod -method POST -Uri \"https:\/\/$serverName\/api\/v1\/auth\/update?auto=false\" -Body ($changePassBody | ConvertTo-Json) -ContentType \"application\/json\"\n\n# Output of Invoke-RestMethod from above\nmessage\n-------\nPassword updated successfully.\n<\/code><\/pre>\n\n\n\n<p>With this test successful, I tested the code against a collector appliance with an expired password and it worked there also.&nbsp;<\/p>\n\n\n\n<p>It\u2019s outside of the intent of this brief article but to have this be a complete solution, the remaining tasks to fully automate this process would include:\u00a0<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Reading in a complete list of Skyline Collectors\u00a0(either from a list in the script or CMDB solution)<\/li>\n\n\n\n<li>Retrieving the current password for each collector (from a privileged access management tool like Cyberark \/ Thyotic)<\/li>\n\n\n\n<li>Auto-generating a new password for each collector&nbsp;<\/li>\n\n\n\n<li>Storing the new password in the privileged access management vault for each collector\u00a0<\/li>\n\n\n\n<li>Schedule this as a recurring task<\/li>\n<\/ul>\n\n\n\n<p>Hopefully this has given you a helpful example of using your browsers Developer Tools to investigate APIs as well as writing a sample script to use what you find.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Too frequently I login to my Skyline Collector and am immediately required to change the password. Follow along with me as I explain how I figured out how to use automation to reduce the frustration of this process. The Skyline &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/keep-it-secure-automate-skyline-collector-admin-password-changes\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[9,3],"tags":[],"class_list":["post-1789","post","type-post","status-publish","format-standard","hentry","category-lab-infrastructure","category-scripting"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1789","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=1789"}],"version-history":[{"count":2,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1789\/revisions"}],"predecessor-version":[{"id":1794,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1789\/revisions\/1794"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=1789"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=1789"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=1789"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}