{"id":132,"date":"2014-12-30T14:07:36","date_gmt":"2014-12-30T14:07:36","guid":{"rendered":"http:\/\/toolbox.pingvinfeszek.hu\/?p=132"},"modified":"2014-12-30T14:12:12","modified_gmt":"2014-12-30T14:12:12","slug":"ubuntu-command-line-how-to-connect-to-wi-fi-wpawpa2","status":"publish","type":"post","link":"https:\/\/wp.gaborhargitai.hu\/ubuntu-command-line-how-to-connect-to-wi-fi-wpawpa2\/","title":{"rendered":"Ubuntu Command Line – How To Connect To Wi-Fi WPA\/WPA2"},"content":{"rendered":"
<\/p>\n
First and foremost, you will need to have wpa-supplicant<\/strong> installed, otherwise it won’t work. Ubuntu does installs this be default, but to be on the safe side you can install the required package with this command:<\/p>\n <\/p>\n sudo apt-get install wpasupplicant<\/p>\n <\/p><\/blockquote>\n So far so good, next up we’ll be creating 2 files alongside eachother, the first being:<\/p>\n wireless-wpa.sh<\/strong><\/p>\n #!\/bin\/sh #shut down interface #set ad-hoc\/management of wireless device #enable interface #stop any persistent wireless wpa2 sessions #apply WPA\/WPA2 personal settings to device #obtain an IP address <\/p>\n Be extra sure to corrent the have the correct iface<\/strong> value in your script!<\/p>\n Our second file would be:<\/p>\n wireless-wpa.conf<\/strong><\/p>\n # config file using WPA\/WPA2-PSK Personal key.<\/p>\n ctrl_interface=\/var\/run\/wpa_supplicant<\/p>\n network={ <\/p>\n Should you have absolutely no clue about the name of your Router’s or Access Point’s ESSID, issue this command to have the Wi-Fi card look around for available wireless networks (wlan0<\/strong> is the name of your wireless card as per ifconfig<\/strong>):<\/p>\n <\/p>\n sudo iwlist wlan0 scan<\/p>\n <\/p><\/blockquote>\n Now issue the following commands:<\/p>\n <\/p>\n sudo chmod 755\u00a0wireless-wpa.sh <\/p>\n Finally,\u00a0now bring up the connection by running:<\/p>\n <\/p>\n sudo .\/wireless-wpa.sh<\/p><\/blockquote>\n <\/p>\n This is pretty useful if you do not wish to deal with \/etc\/network\/interfaces and soforth.<\/p>\n
\niface=wlan0<\/p>\n
\nifconfig $iface down<\/p>\n
\niwconfig $iface mode Managed<\/p>\n
\nifconfig $iface up<\/p>\n
\nkillall wpa_supplicant<\/p>\n
\nwpa_supplicant -B -Dwext -i $iface -c .\/wireless-wpa.conf -dd<\/p>\n
\ndhclient $iface<\/p><\/blockquote>\n
\nssid=”my_router_id”
\nscan_ssid=1
\nkey_mgmt=WPA-PSK
\npsk=”1234567890″
\n}<\/p><\/blockquote>\n
\nsudo chmod 644 wireless-wpa.conf<\/p><\/blockquote>\n