{"id":11394,"date":"2022-02-06T23:45:35","date_gmt":"2022-02-07T06:45:35","guid":{"rendered":"https:\/\/www.apolonio.com\/blog\/?p=11394"},"modified":"2022-02-06T23:45:35","modified_gmt":"2022-02-07T06:45:35","slug":"creating-users-in-lab","status":"publish","type":"post","link":"https:\/\/www.apolonio.com\/blog\/?p=11394","title":{"rendered":"Creating Users In Lab"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">First step in my new DemoLab2022 is to get the fake users created.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Since this is home lab targeted I needed to figure out how to get the users a local but synced.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Being a Linux guy I knew how to script a local user, but needed to script smb and httpd users<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here is how I did it in Linux<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">useradd -u 1001 -G wheel -c \"Alice Johnson\" alice\r\nset +o history\r\nPASSWORD=\"xxxxxxxx\"\r\necho -e $PASSWORD\"\\n\"$PASSWORD | passwd alice\r\necho -e $PASSWORD\"\\n\"$PASSWORD | smbpasswd -a alice\r\nhtpasswd -b \/etc\/nagios\/passwd alice $PASSWORD\r\nset -o history<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Windows was easy, being a former windows admin<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">net user alice xxxxxxxx \/ADD \/FULLNAME:\"Alice Johnson\"\nnet localgroup \"Remote Desktop Users\" \"alice\" \/ADD<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The NAS was a little different, something new for me, you cannot log in and user adduser to create accounts, you have to use the API.  Luckily there were python examples.  Here is the python example which is run from the linux box<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/usr\/bin\/python3\r\nimport json\r\nimport requests\r\nr = requests.post(\r\n  \"https:\/\/nas\/api\/v2.0\/user\/\",\r\n  auth=(\"root\", \"freenaspassword\"),\r\n  headers={\"Content-Type\": \"application\/json\"},\r\n  verify=False,\r\n  data=json.dumps({\r\n       \"uid\": \"1001\",\r\n       \"username\": \"alice\",\r\n       \"home_mode\": \"755\",\r\n       \"group_create\": True,\r\n       \"password\": \"xxxxxxxx\",\r\n       \"microsoft_account\": True,\r\n       \"shell\": \"\/usr\/local\/bin\/bash\",\r\n       \"full_name\": \"Alice Johnson\",\r\n       \"email\": \"alice@demolab.local\",\r\n   })\r\n )\r\nprint(r.text)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">There were things that bugged me like the Cert not being legit (it is signed by an internal CA) and they recommended the user of a token to log in vs a username and password.  But this worked.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Posting a little early today, going to which Spiderman No Way Home, yes it came out a few weeks ago, but waited for theaters to clear out before I went.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Weight: 351.8<\/p>\n","protected":false},"excerpt":{"rendered":"<p>First step in my new DemoLab2022 is to get the fake users created. Since this is home lab targeted I needed to figure out how to get the users a local but synced. Being a Linux guy I knew how &hellip; <a href=\"https:\/\/www.apolonio.com\/blog\/?p=11394\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,3,9],"tags":[],"class_list":["post-11394","post","type-post","status-publish","format-standard","hentry","category-technical","category-training","category-weighin"],"_links":{"self":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=11394"}],"version-history":[{"count":1,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11394\/revisions"}],"predecessor-version":[{"id":11395,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/11394\/revisions\/11395"}],"wp:attachment":[{"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=11394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=11394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.apolonio.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=11394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}