Create New User Account From Command Line?
How can I create a new user account from the command line? I'd like it to be in the admin wheel group, but below ID 500 so it doesn't show up in the users login prefs.
How can I do this ? AddUser doesn't work in mac os x bash (panther) or in jaguar either.
I need to be able to do this to setup machines I remotely admin for clients. I have them run a realbasic program that issues commands in the command line. It creates my default "remote maintenance" package so I can help them when they need it.
How can I do this ? AddUser doesn't work in mac os x bash (panther) or in jaguar either.
I need to be able to do this to setup machines I remotely admin for clients. I have them run a realbasic program that issues commands in the command line. It creates my default "remote maintenance" package so I can help them when they need it.
Comments
Can you give me an example based on what I want? Lol, I'm lost with this tool.
For example, I want to create a "God" user named "bob" with password "bob" that doesn't show up in the user login window.
Thanks again!
Based on niutil I found this at macosxhints, but it doesn't quite answer everything. Also how would I remove the user?
http://www.macosxhints.com/article.p...0&query=niutil
Originally posted by Jellytussle
man niutil.
sudo niutil -create / /users/bob
sudo niutil -createprop / /users/bob uid 006
sudo niutil -createprop / /users/bob realname "FTP User"
sudo niutil -createprop / /users/bob home "/Users/ftpuser"
sudo niutil -createprop / /users/bob shell "/bin/tcsh"
I'm not clear on these two commands however. Is this the user ID group? How could I add the person to the administrator group? It appears the test I created can only read files.
sudo niutil -createprop / /users/bob gid 20
What does this do with the password? Is it setting it?
sudo niutil -createprop / /users/bob passwd "*"
If the command above sets the password do I really need to do this?
sudo passwd test
Here's how to remove the account later on. It removes all the properties you created for that user when you delete his account. So you only need one command
sudo niutil -destroy / /users/bob
Originally posted by inkhead
I'm not clear on these two commands however. Is this the user ID group? How could I add the person to the administrator group? It appears the test I created can only read files.
Code:
sudo niutil -createprop / /users/bob gid 20
that sets the group. you should look inside /groups (i think its /groups, if not then something similar) to match the groups' names with gids. i'm pretty sure there is a way to add multiple groups too.
What does this do with the password? Is it setting it?
Code:
sudo niutil -createprop / /users/bob passwd "*"
If the command above sets the password do I really need to do this?
sudo passwd test
the '...niutil...passwd "*"' command inserts a dummy password. basically, it just makes sure that the passwd field is there under the user. passwords inside NetInfo are actually stored encrypted, so you'd have a hard time using niutil to add in a real one. using 'sudo passwd <userName>' is the best way to change the password. so, you should first use niutil to add in the dummy one, then passwd to set it. if you don't set the password, then its not possible to login as the user (which isn't necessarily a bad thing).
Also, if you are averse to the CLI, you can use the NetInfo.app program to do most of this stuff, including viewing other NI values (like checking group names->numbers). You may want to open it up, and look at the other users, to see if you want to add anything else to your new user(s).
sudo niutil -mergeprop / /groups/mygroup users name
You can generate a crypt password with openssl - run it and then type passwd. The resulting hash can be dropped straight into the NI db.
Oh, and all this changes with Panter
edit: fixed command so it actually works: helps maintain my aura of omniscience
Jelly,
Can you please give me an example of how to create the password and drop it right in the netinfo database? This seems like the ideal solution so I don't have to do the sudo passwd username and fill in the two prompts to create the users password.
Thanks again!
Originally posted by Jellytussle
to add yourself to a group, just add your user's name to the 'users' property of that group, eg
Code:
sudo niutil -mergeprop / /groups/mygroup users name
You can generate a crypt password with openssl - run it and then type passwd. The resulting hash can be dropped straight into the NI db.
Oh, and all this changes with Panter
edit: fixed command so it actually works: helps maintain my aura of omniscience
openssl passwd cheese
returns a hash for 'cheese'.
hth