Mac OS X Server,  Mac Security

Creating Accounts in OS X Server with serversetup

I usually create users by dropping a couple of files or by using a dscl script.  But in Mac OS X Server it’s even easier than that.  You can use the serversetup command, by default located in /System/Library/ServerSetup to do so with the -createUserWithID option.  Following the -createUserWithID option, use the long name, then the short name, then the password and finally the UID of the intended user (that’s position 1 = long name, position 2= short name, position 3 = password and position 4 = UID).  Therefore, if /System/Library/ServerSetup is your working directory then the following command can be used to create a user with a full name of Charles, a short name of charles2, a password of mypassword and a UID of 405:

./serversetup -createUserWithID Charles charles2 mypassword 405
This is a little easier than using a larger script or performing a file drop assuming you have the server tools installed, which you will need in order for the serversetup command to be present.