Skip to main content
Question

add user script


Forum|alt.badge.img+7

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

7 replies

Forum|alt.badge.img+7
  • Author
  • Contributor
  • 23 replies
  • December 12, 2022

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


Forum|alt.badge.img+17
  • Valued Contributor
  • 231 replies
  • December 12, 2022

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. 


mickgrant
Forum|alt.badge.img+12
  • Contributor
  • 140 replies
  • December 13, 2022

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

 

 


Forum|alt.badge.img+7
  • Author
  • Contributor
  • 23 replies
  • December 13, 2022
mickgrant wrote:

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

 

 


Hmmm....this is something I have never done before. Can you give some
better directions?

Megan Ramola
Technology Assistant
Becker School District
763-261-4501 ext 3153

Forum|alt.badge.img+7
  • Author
  • Contributor
  • 23 replies
  • December 13, 2022
joshuasee wrote:

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. 


Yes - I did read that dscl was heading out the door, I just needed to get
it to work at least once, and then I can make some changes. If you have a
full script using sysadminctl that you'd like to share that would be
great. I am very new to all of this.

Megan Ramola
Technology Assistant
Becker School District
763-261-4501 ext 3153

mickgrant
Forum|alt.badge.img+12
  • Contributor
  • 140 replies
  • December 13, 2022
mramola wrote:
Hmmm....this is something I have never done before. Can you give some
better directions?

Megan Ramola
Technology Assistant
Becker School District
763-261-4501 ext 3153

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.


Fluffy
Forum|alt.badge.img+10
  • Honored Contributor
  • 209 replies
  • December 16, 2022

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.

https://github.com/freegeek-pdx/mkuser


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings