Coming from Debian I had some trouble getting netcfg to do my bidding.
I found it easier in debian just using wpa_supplicant something along the lines of
in /etc/network/interfaces:
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf
and /etc/wpa.conf contains the meat of the wifi connection:
network={
ssid="myssid"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="mywifi preshared key in clear"
}
you can have several network definitions. I use it for basic roaming.
The psk in clear text in not ideal. you can mitigate it by giving your conf file a 600 permission. There is also the possibility to store a hash of the key. Check the man wpa_supplicant for more details.
Finally this sets up a system wide network profile which is exactly my use case (headless wireless appliance). Wicd and the like are also able to handle user network profiles.
As a side note: it is possible to install and use network manager on the command line only. check man nmcli . this may or may not fit your need.