Tuesday 15 March 2011

Adding local users to OS X via Command Line - Apple Remote Desktop

Media wanted all apple macs to have a "Media" login, and show a list of users for the login window. As I'd done this before I thought it'd be pretty straight forward. I found the script I used to do an apple event previously:


dscl / -create /Users/apple
dscl / -create /Users/apple UserShell /bin/bash
dscl / -create /Users/apple RealName "Apple"
dscl / -create /Users/apple UniqueID 505
dscl / -create /Users/apple PrimaryGroupID 1000
dscl / -create /Users/apple NFSHomeDirectory /Users/apple
dscl / -passwd /Users/apple "apassword"

Unfortunatley it came up with an error:

Data source (/) is not valid

I figured last time I used the command it was on OS X 10.4.11, and we're now on OS X 10.5.8. I searched on the old internet and found this post, which might have been where I originally got the commands. I also found someone else having the same error. There was a few solutions, but by far the easiest was simply replacing the '/' with a '.'  . i.e.


dscl . -create /Users/media
dscl . -create /Users/media UserShell /bin/bash
dscl . -create /Users/media RealName "Media"
dscl . -create /Users/media UniqueID 505
dscl . -create /Users/media PrimaryGroupID 1000
dscl . -create /Users/media NFSHomeDirectory /Users/media
dscl . -passwd /Users/media "adifferentpassword"

The only problem I had after this (if you can call it a problem) was getting it to use a different picture. The one it seems to set is a networked picture. I did a little searching but found nothing. I'm sure the 'dscl' command could probably do it, but it seems to have a large man page on it, doh! If I get more time (unlikely) then you can get the dscl command to read the settings for a user already set up.

To set up the login screen I simply used the settings in Workgroup Managers computer management settings for "Login". Simple.

Anyway. this has definitely saved me a little time in the future!!

No comments:

Post a Comment