In the past there have been several published hints on the /usr/sbin/networksetup
command. However, until recently (well since 10.6.x) that command was not able to add passkeys to the keychain. I just received 500 new MacBooks to image in my enterprise and these brand new ones will only run 10.6. The rest of our deployment is still on 10.5.8 because we never had the desire to re-image 40 OS X Servers and 8,000 clients with 10.6.
So, I just modified my post image shell script to have a line that does a simple case statement and if it outputs 10.6* it executes this line of code:
/usr/sbin/networksetup -addpreferredwirelessnetworkatindex Airport my_ssid 0 my_security my_passkey
Where my_ssid is the SSID
of your network, my_security
is the level of encryption (WEP, WPA, WPA2, etc) and my_passkey
is your encryption passkey for your wireless network. I've tested this out on my post image shell script on about 10 clients so far after imaging them with 10.6. So far it works pretty well, and is a key step in us not having any post configuration to do by hand after a machine is imaged.
I know this is a bit of an older hint since 10.6 has been out for a while now but I searched it did not find anything on this, then I read the manual page from the Apple Developer site
and found that command.
I haven't tested this one.]