How can I find out what type of security a wireless access point (essid) is using? wep/wpa/wpa2 (preferably using commandline tools)
How can I find out what type of security a wireless access point (essid) is using? wep/wpa/wpa2 (preferably using commandline tools)
You can use the
iwlist
tool to print out all details of access points nearby. Assuming your wireless device is calledwlan0
:The output from iwlist will show each 'Cell' (or access point) that it finds, including the following details about the encryption type:
This indicates that a network near me is using WPA2, using a pre-shared key (PSK).
nmcli is command-line client for NetworkManager. It can be used to view security types of nearby wireless access points.
Result will show up as following:
NetworkManager
has a great command-line backend callednmcli
. The small draw-back is that some commands in 15.04 differ from 14.04 version ofnmcli
.Ubuntu 14.04
nmcli -f NAME con status
allows listing names of the current connections. For example,Now, to list specific details about a connection, we can do
nmcli con list id "WifiName"
. To be more specific, we are looking for line that sayskey-mgmt
.Thus we know , this wifi uses WPA protection.
Another hint is the following line:
Now, how do we put this into the same script ? If you have only one connection established ,
Here we merely manipulate
nmcli
with -t flag to give us only the name of wifi Access Point without the pretty header,and use it in parameter substitution brackets$( . . .)
and give it as an input tonmcli con list id
to list data about that Access Point. Finally,awk
just filters out the necessary line.If you have wifi connection established but also Ethernet connected,
nmcli -f NAME con status
will output multiple lines. I suggest filtering out wifi from that list, withnmcli -f NAME,DEVICES con status | awk '/wlan0/ {print $1}'
. The rest of the processing would be the same as above.Ubuntu 15.04
The above commands translate in 15.04 as follows:
nmcli -t -f NAME,DEVICE con status | awk -F':' '/wlan0/{print }'
to get the name of established connection onwlan0
nmcli con show "ConnectionName"
to list details about your established connection.Side note: in Ubuntu 14.04 there is
nm-tool
which lists information about your current connections in a readily organized format, however it is not present in 15.04 , hence I suggest you study and play with it on your own