{"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
\niface=wlan0<\/p>\n

#shut down interface
\nifconfig $iface down<\/p>\n

#set ad-hoc\/management of wireless device
\niwconfig $iface mode Managed<\/p>\n

#enable interface
\nifconfig $iface up<\/p>\n

#stop any persistent wireless wpa2 sessions
\nkillall wpa_supplicant<\/p>\n

#apply WPA\/WPA2 personal settings to device
\nwpa_supplicant -B -Dwext -i $iface -c .\/wireless-wpa.conf -dd<\/p>\n

#obtain an IP address
\ndhclient $iface<\/p><\/blockquote>\n

 <\/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={
\nssid=”my_router_id”
\nscan_ssid=1
\nkey_mgmt=WPA-PSK
\npsk=”1234567890″
\n}<\/p><\/blockquote>\n

 <\/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
\nsudo chmod 644 wireless-wpa.conf<\/p><\/blockquote>\n

 <\/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

The original guide can be found by clicking here<\/a>.<\/p>\n

 <\/p>\n

 <\/p>\n","protected":false},"excerpt":{"rendered":"

  First and foremost, you will need to have wpa-supplicant 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:   sudo apt-get install wpasupplicant   So far so good, next up we’ll be creating 2 files alongside […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,7],"tags":[],"_links":{"self":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts\/132"}],"collection":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/comments?post=132"}],"version-history":[{"count":7,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts\/132\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/posts\/132\/revisions\/139"}],"wp:attachment":[{"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/media?parent=132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/categories?post=132"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.gaborhargitai.hu\/wp-json\/wp\/v2\/tags?post=132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}