Ubuntu Server - How to connect to wireless WPA2 personal network?

1) Install the package wpasupplicant.

2) Then write:

sudo su
wpa_passphrase [SSID] >> /etc/wpa_supplicant.conf
exit

Where [SSID] is SSID of point where you want to connect. After entering this command, you have to write password for that acces point.

3) Run wpa_suplicant with new config file.

sudo wpa_supplicant -B -D wext -i wlan0 -c /etc/wpa_supplicant.conf

Make sure that your interface is wlan0, or change it if needed!

-B is for background running.

-D is used driver.

-i is interface.

4) You should be connected now :)


I used instructions from https://wiki.debian.org/WiFi/HowToUse#WPA-PSK_and_WPA2-PSK.

Don't forget to remove anything you added in etc/rc.local as it could conflict

First, make sure you have installed (can't remember if its installed by default or not) the package "wpasupplicant"

Then you need to edit the "/etc/network/interfaces" file.

The stanza used was based on the example from the above link (reproduced below):

auto wlan0
iface wlan0 inet dhcp
    wpa-ssid mynetworkname
    wpa-psk mysecretpassphrase

You will need to check which interface your Wifi card is (its usually wlan0) and you need the key and ssid of your wireless network.


Here are my notes for connecting to an

Android portable hotspot

/etc/network/interfaces

iface wlan1 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant_android.conf

/etc/wpa_supplicant/wpa_supplicant_android.conf

network={
    ssid="AndroidAP"
    psk="password"
}

Notes

  • use $ ifup wlan1 to bring the interface up. Insert 'auto wlan1' in the line before 'iface wlan1 inet dhcp' to have linux automatically bring up the interface
  • $ip link is a useful bash command to identify the wireless identifier (wlan*).

iPad/MAC personal hotspot/wifi

/etc/network/interfaces

iface wlan1 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant_ipad.conf

/etc/wpa_supplicant/wpa_supplicant_ipad.conf

network={
    ssid="Hamish’s iPad"
    psk="myPassword"
    proto=RSN
    key_mgmt=WPA-PSK
    pairwise=CCMP
    auth_alg=OPEN
}

Notes

  • Beware the "’" character, it is not the same as "'"
  • Unlike with the Android network, wpa supplicant requires additional paparameters to connect to the MAC based wifi...