Can Ubuntu server connect to a WPA2 encrypted wireless network?

13,203

Solution 1

You can install a GUI interface to Ubuntu server to get Network Manager or following the wpa_supplicant on this page (https://help.ubuntu.com/community/WifiDocs/WPAHowTo).

Solution 2

Note: First off you will want to make sure that the server has wpa_supplicant installed. Servers don't always have it and that can make it difficult if you can't connect it to Ethernet at least once.

This is how I do it. (be sure to use your ip numbers and network interface name)

Wont need this part for a server it is just if you wanted to kill off everything that would be interfering on a desktop.

sudo stop network-manager
sudo killall wpa_supplicant #must stop network-manager before this as it resurrects it.
sudo killall nm-applet

this only needs to be done once unless the file gets trashed. (you can put the config anywhere really)

wpa_passphrase "YOUR_ESSID" | sudo tee /etc/wpa_supplicant.conf #and type your password

-B for background -s to log to syslog -c to tell it where the config is. -i interface

sudo wpa_supplicant -B -s -c /etc/wpa_supplicant.conf -i wlan0

for DHCP just use

sudo dhclient wlan0

for static ip

sudo ifconfig wlan0 192.168.1.12 #Be sure to set you ip to what works for you.

should be able to ping your router by ip. $ ping 192.168.1.1

sudo route add default gw 192.168.1.1 # use the ip of you router

should be able to ping the net at large. $ ping 8.8.8.8

echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

should be done. $ ping google.com

This will not last through a reboot. To make this persist through a reboot,

sudo nano /etc/network/interfaces

Add this to the bottom (substitute for wlan0 if you have a different interface):

auto wlan0
iface wlan0 inet dhcp
pre-up wpa_supplicant -B -c /etc/wpa_supplicant.conf
post-down killall -q wpa_supplicant

Note that you might not have the KILLALL component installed if you have a minimal server. You can get killall with:

aptitude install psmisc
Share:
13,203

Related videos on Youtube

Lyrositor
Author by

Lyrositor

Updated on September 17, 2022

Comments

  • Lyrositor
    Lyrositor almost 2 years

    I'm planning to maybe install Ubuntu server on an old machine. But my question is: can I install Ubuntu server on a machine and have it connect to my home network - wirelessly? I can't use a cable in this case.

  • Lyrositor
    Lyrositor over 13 years
    Does that wpa_supplicant require a graphical interface too?
  • JHollywood
    JHollywood over 13 years
    wpa_supplicant can be configured from the command line.
  • JanC
    JanC over 13 years
    NetworkManager can work without a GUI too...
  • Gervase Markham
    Gervase Markham almost 10 years
    Above answer is near-perfect, although I had to add a "-i wlan0" to the pre-up line which calls wpa_supplicant. (This matches the example given further up the answer.)