Create User in OSX Terminal Why you might do this then How?

tanut aran
2 min readSep 4, 2021

Why I might do this?

You are on SSH remote login to your Mac to make a user for your colleague.

How you do this?

The dscl command.

dscl .

I prefer interactive session so that I don’t need to prefix anything with sudo dscl . The dot mean ‘here’ at this machine. Here is the step.

sudo dscl .
cd /Users
create user-2
create user-2 UserShell /bin/zsh
create user-2 PrimaryGroupID 20
create user-2 NFSHomeDirectory /Users/user-2
create user-2 UniqueID 502
passwd user-2

For NFSHomeDirectory is home directory, you can create and give perm by

sudo mkdir /Users/user-2
sudo chome user-2:staff /Users/user-2

For PrimaryGroupID , the default for staff is 20 you can recheck it with

dscl . read /Groups/staff

For UniqueID anything above 500 is okay.

You at least need all of these to allow login.

Check your login

Switch user to check your login

su user-2

Allow SSH Login

Assume you already generate SSH key for this user. Then you need one extra perm to allow them to login.

sudo dscl . append /Groups/ GroupMembership <your_user_name>

Issues I found

For some property, it doesn’t allow you to edit even with sudo

sudo dscl . -change /Users/user-2 UniqueID 503 504<main> attribute status: eDSPermissionError                                                                                                                                                           <dscl_cmd> DS Error: -14120 (eDSPermissionError)

Hope this help !