I have a desktop computer in my son's room that runs Ubuntu and I have repurposed an old laptop as a music server connected to the stereo. Neither location is in the same room with my cable modem, and hard-wiring is inconvenient.
In the case of the desktop computer, I want my son to be able to boot up and not have to log in. Ubuntu facilitates this and allows a user to log in automatically without having to enter a password (and still allow my username, with administration privileges, to be password protected), but the storage of the wifi key is a little wonky. And on the rare occasions when the connection flaked out, he couldn't reconnect.
I have a different problem on the laptop being used as a media server. It is sitting on a shelf wedged in with the A/V components. The intention is that it will be a headless server, but to connect it to the network it must be opened up and a user must be logged in. If it was hard-wired to the network it would connect automatically, but since it is on wifi the extra step is necessary. This computer has Crunchbang Linux installed on it in the hopes that the lack of Gnome or KDE will keep the power consumption (and heat generation) down. Also, because it is a nice light distribution for creating a server that still presents a usable user interface when needed.
Both of these problems were resolved by adding some info to the /etc/network/interfaces file. By adding the following to the end of that file (which you may have to do with sudo or root access), the wifi will be connected automatically:
# Connect to home network via wifi
iface wlan0 inet dhcp
Of course you should replace the above ssid an psk with the real ones from your network. This is dependent on the wpasupplicant package, which is present on both Crunchbang and Ubuntu, but your system may be different. And this assumes you are using WPA as your wifi security, which I recommend over WEP or over lack of security.
One more note: you may not want users to have access to the WPA security key. Ubuntu and Crunchbang both allow any user to view the interfaces file, but it is possible to set the security so only the root user can see it. Just enter
sudo chmod 0600 /etc/network/interfacesand the security will be set.
Submitted by richard on Sat, 02/18/2012 - 16:07