34

As a learning experiment, I'm trying to turn Ubuntu Desktop into a server. I was able to disable X at boot time and now, I am trying to get my computer to connect to my WiFi network at boot time, before any user logs in. That way, I won't have to be physically near my computer every time it reboots. I've set up the WiFi connection using the Network Manager if that can help somehow (would be nice not having to reconfigure it again!).

4 Answers4

46

I found out how to do it :) Simply go into Network Manager > Edit Connections. Select your connection, click Edit and check Available to all users.

You may also need to add a line for each interface that you want to automatically come up at boot time in /etc/network/interfaces:

auto eth0
auto wifi0
Zanna
  • 70,465
  • Is that working?I have already tried that but it's not working. – karthick87 Dec 06 '10 at 04:12
  • Yep it's working here. The connection doesn't use DHCP but I doubt it wouldn't work because of DHCP. – Olivier Lalonde Dec 06 '10 at 04:17
  • 6
    The interface cards won't always be named "eth0" and "wifi0". You can find the names of the ethernet interfaces with "cat /proc/net/dev " or "ifconfig". – Jonathan Dec 11 '15 at 11:05
  • 2
    is doesn't work on my fresh install of Ubuntu 16.04. The network connection is made only after a user logs in. This makes working remote extremely difficult. – L. D. James Jun 15 '16 at 09:54
  • 1
    It won't work with my 16.04 LTS. It requires logging in on the console, then it connects automatically. Yes, it is checked to be available to all users, even thoguh I am the only one. --> And just to be funny, on the login screen it offers the WiFi networks but when I try to pick on it says insufficient privilege. Ha Ha. Whomever is doing their UI QC has a sense of humor. – SDsolar Jul 16 '17 at 09:29
  • 2
    Mine says "All users may connect to this network" – Guillermo Ruffino Feb 08 '18 at 14:45
  • 2
    Does not work on Ubuntu 18.04 ... – kkazakov Jun 07 '18 at 08:25
  • 1
    Works Perfect in 20.04! Thanks! – EODCraft Staff Jan 23 '22 at 17:37
30

If you are using Ubuntu 16.x, navigate to /etc/NetworkManager/system-connections/. There you will find a file with the same name as your wireless network. This file contains your wifi credentials and settings. Edit it, find the line with permission=, and remove everything after the = sign (or the whole line).

Restart and you can connect before login.

dhaupin
  • 105
  • 5
  • 3
    Additionally, psk-flags=1 means the password is stored encrypted in users home dir. it prob won't work before login in that case. It's less secure, but if you need this to work, you can replace pask-flags=1 with psk=MyWifiPassword. More about that thought: https://lauri.xn--vsandi-pxa.com/cfgmgmt/network-manager-system-connections.html – dhaupin Apr 14 '17 at 20:37
  • There is nothing after the = sign. And it does not connect until I log in at the console. Since WiFi is my only connection I can't do it remotely - this makes me have to travel to the computer to recover from a reboot. It is on a UPS but even that can only last so long. – SDsolar Jul 16 '17 at 09:48
  • Perfect !!! This solves my problem...Thank you so much.... – Pei JIA Jan 14 '20 at 06:07
  • Worked for me - Commented out the 'permission=...' line - Running Ubuntu Bionic 18.04.3 LTS on a Pi4b – dave58 Sep 26 '20 at 17:56
  • psk=password did the trick for me – Daniel Jul 12 '22 at 02:18
9

dhaupin's solution solved my problem with minor modifications:

My /etc/NetworkManager/system-connections/ file did not have a permission= line. But it did have a psk-flags=1 line. Commenting it out and adding a psk="MyWifiPassword" line fixed the Network-Mangler problem.

Rebooted and it came up online without logging in.

Zanna
  • 70,465
3

Edit the interfaces file /etc/network/interfaces

sudo -H gedit /etc/network/interfaces

Add the following,

auto ra0
iface ra0 inet dhcp
wpa-conf /etc/wpa_supplicant.conf
Zanna
  • 70,465
karthick87
  • 81,947
  • Is there a technical difference between the way I did it (see my answer) and yours? – Olivier Lalonde Dec 06 '10 at 04:07
  • Olivier, I think your solution is more up-to-date, depending as it does on a relatively new feature of NetworkManager. Kathick's solution, on the other hand, circumvents NetworkManager altogether. Your solution might be more robust as NetworkManager keeps track of the connection and reconncects if it is lost temporarily (although the interfaces way might do that too in some cases). – loevborg Dec 06 '10 at 15:15
  • I hate to mess with that file, plus this computer is alreayd entered into the hosts file of all the other computers as a static IP. wpa_supplicant is fine. And yet it still doesn't do it. – SDsolar Jul 16 '17 at 09:50
  • This command is much better for more advanced cases, where one doesn't want to have network manager to interfere in complex network configuration. Like when setting up an access point. – Igor Stoppa May 23 '20 at 15:04