I have been wondering on how to do this for a long time.
Here's the clue:
On Mac OS X Server side there is this tool:
Amongst a lot of other features, it offers these functions:
serversetup -setAutoLoginUser Name UID Password
Set the autostart user using the name and password supplied.
Returns the current AutoLoginUser.
serversetup -clearAutoLoginUser UID
Disables AutoLogin feature.
Now what if I copied this tool to a Mac client?
It works. Well sort of. Sometimes.
It works if the script is executed while logged in locally on the machine.
But that's not what I want.
But I found another hint here:
What you can do is copy the file/private/etc/kcpassword generated on one machine to all the macs you want to log in automatically. It contains an encrypted password. Unfortunately there is no documented way of generating this file on a client. Hmm.
Then all you have to do is change the login preferences by issuing the following commands:
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser yourusername
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUID yourUIDnumber
There is a cooler way to do this.
I found a utility whose name is 'kcpasswd'.
kcpasswd is a command line application that changes a user's KeyChain password.
That's not exaclty that I was looking for, but it comes real close.
So I sent an email to the author of 'kcpasswd' if there were any chance that he could support generating the /etc/kcpassword file.
After a while I received an email from Phill Tejada telling me that he had this new tool called 'loginoptions' which does just that.
Way cool and thanks a lot Phill.
Oh yes, the links, I almost forgot: