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?
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 .
create user-2 UserShell /bin/zsh
create user-2 PrimaryGroupID 20
create user-2 NFSHomeDirectory /Users/user-2
create user-2 UniqueID 502
NFSHomeDirectory is home directory, you can create and give perm by
sudo mkdir /Users/user-2
sudo chome user-2:staff /Users/user-2
PrimaryGroupID , the default for
20 you can recheck it with
dscl . read /Groups/staff
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
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/com.apple.access_ssh 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 !