Have Ubuntu auto-connect to wireless AP without logging in

Depending on the physical security of the box, you could configure gdm to auto-login using an unprivileged user account that has access to the wireless device. Then Network Manager would handle all of the auto-reconnection issues.

This is configured under System | Administration | Login Window | Security


First, it's worth knowing that a default Ubuntu Desktop installation uses a piece of software named NetworkManager to manage the network.

The advantage of that is that it's very useful on laptops where you move around among different networks a lot, since it makes it very easy to find and connect to wireless networks.

The drawback is that it seems you must be logged in to get a network connection, and that's obviously less than optimal for a server.

Instead of running NetworkManager, the way to go is to configure your network settings in the file /etc/network/interfaces, a file which will be read at startup. I'm a bit uncertain on how to disable networkmanager, but I think it will detect that an interface has already been configured and stay away from it when you login.

Anyway, assuming that your network card is named ath0, you need to add something like the example below to /etc/network/interfaces:

auto ath0
iface ath0 inet static 
    address 10.20.30.40
    netmask 255.255.255.0
    gateway 10.20.30.1
    wireless-essid ESSID
    wireless-ap 00:60:1D:01:23:45
    wireless-key 0123-4567-89

It's been a while since I tested doing this, so the above is untested. The following manpages should be of help:

  • interfaces(5)
  • iwconfig(8)
  • wireless(7)