I would like to be able to create new users in Mac OS X 10.5 remotely after ssh'ing into the machine. How do I do this?
|
Use the dscl command. This example would create the user "luser", like so:
You can then use passwd to change the user's password, or use:
You'll have to create /Users/luser for the user's home directory and change ownership so the user can access it, and be sure that the UniqueID is in fact unique. This line will add the user to the administrator's group:
|
|||||||||||||||||||||
|
|
(This answer should be considered an addendum to fill in some blanks in palmer's procedure) To pick an unused UniqueID for you new user, you could use:
...then use the sequence of dscl commands palmer gave to create the account, and then create the new user's home directory with:
(there is a createhomedir command, but it didn't work when I tested it.) |
|||||||||
|
|
If you have a bunch of users to create, it is possible to create a structured text file and pass it to Apple's Command-Line Administration Guide has a whole chapter on users and groups. |
||||
|
|
|
Another way to pick and choose a unique user ID before creating an account is just to look through the list and check that the one you want to use is not there:
Handy if you need to use a certain ID |
|||||||||
|
|
I've leveraged the different answers here to come up with what I think is a nice script to create user accounts. Admittedly, this isn't designed for running a command at a time from ssh; it is moreso designed to be a script run when compiling a package-based image of OS X (as created by Casper Imaging or InstaDMG).
The script does let you specify which groups a user should belong to. It appears to me that this might differ depending upon the version of OS X you are running. I get different results when I run |
|||||||||||||||||
|
|
I started a little wrapper about The framework is there for all the parameters, so if you want to take advantage of GitHub's awesome social features, it's easy to do. |
|||
|
|
protected by sysadmin1138♦ May 2 '12 at 19:22
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
single_usermode (a security reset) then you'll need to reboot holding downCommand-S, gain write access to the disk per on-screen details, and thenrm /var/db/.AppleSetupDonewhich will let you create a new admin account. Hope this helps someone – New Alexandria Jan 3 '13 at 22:26