Posted on 12-12-2022 10:57 AM
I am trying to add another user to our mac fleet using a script. The script goes through without error and creates a user but no directory folder so when I attempt to log in as the "sub" it just spins and spins.
Here is my script....what am I missing?
sudo dscl . -create /Users/sub
sudo dscl . -create /Users/sub UserShell /bin/bash
sudo dscl . -create /Users/sub RealName sub
sudo dscl . -create /Users/sub UniqueID 1000
sudo dscl . -create /Users/sub PrimaryGroupID 20
sudo dscl . -create /Users/sub NFSHomeDirectory /Users/sub
sudo dscl . -passwd /Users/sub becker
Posted on 12-12-2022 11:15 AM
I got it figured out. In case someone else needs this at some point here is my final script.
sudo dscl . -create /Users/sub
sudo dscl . -create /Users/sub UserShell /bin/bash
sudo dscl . -create /Users/sub RealName sub
sudo dscl . -create /Users/sub UniqueID 1001
sudo dscl . -create /Users/sub PrimaryGroupID 20
sudo dscl . -create /Users/sub NFSHomeDirectory /Users/sub
sudo createhomedir -u sub -c
sudo dscl . -passwd /Users/sub becker
Posted on 12-12-2022 02:43 PM
I would also note that dscl is nearing deprecation as a user creation technique. sysadminctl has an -addUser switch that requires fewer steps and can avoid some of the pitfalls of dscl. You might also want to use sysadminctl to get a secure token for the account created.
Posted on 12-13-2022 05:07 AM
12-12-2022 08:08 PM - edited 12-13-2022 05:17 AM
You can also just create a jamf policy with a custom trigger to create the user and then call it with a one-liner in your script with
this post was written in error, I have no knowledge of jamf schools... my mistake
Posted on 12-13-2022 05:05 AM
Posted on 12-13-2022 05:13 AM
When I wrote that, I thought you were using Jamf Pro,
I have not used Jamf school, so I do not know if that's an option for you.
Posted on 12-16-2022 12:54 PM
On Github there is a script that utilizes sysadminctl called mkuser made by Pico. I haven't used it myself yet, but it's another option and is well documented.