Connecting to wireless networks from command line
- by Balaji
I need to write a shell script which connects to one of the two available wi-fi connections. One is a un secure connection and the other is secure connection.
My question has 2 parts-
1.How to connect to the un-secure (un-encrypted and no password required) connection from command line (or by executing a shell script) when I'm connected to the secure connection?
I followed the steps in http://www.ubuntugeek.com/how-to-troubleshoot-wireless-network-connection-in-ubuntu.html for in-secure connection. I put all the commands in a script and executed it (I made sure that interface name and essid are correct)
- sudo dhclient -r wlan0
- sudo ifconfig wlan0 up
- sudo iwconfig wlan0 essid "UAPublic"
- sudo iwconfig wlan0 mode Managed
- sudo dhclient wlan0
But nothing happens - I'm not disconnected from the current network and connected to the new one
2.When I want to connect to the secure wi-fi network, I understand from http://askubuntu.com/a/138476/70665 that I need to use wpa_supplicant.
But I enter a lot of details in the interface when I connect via UI
security : wpa and wpa2 enterprise
Authentication : PEAP
CA certificate : Equifax...
PEAP version : automatic
inner authentication : MSCHAPv2
username :
password :
How to use wpa_supplicant to mention all these details in the command line? The conf file
network={
ssid="ssid_name"
psk="password"
}
doesn't work for me.