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

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 command.

dscl .

I prefer interactive session so that I don’t need to prefix anything with 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 is home directory, you can create and give perm by

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

For , the default for is you can recheck it with

dscl . read /Groups/staff

For anything above 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 dscl . -change /Users/user-2 UniqueID 503 504<main> attribute status: eDSPermissionError                                                                                                                                                           <dscl_cmd> DS Error: -14120 (eDSPermissionError)

Hope this help !