How to connect to Wi-Fi AP through WPS? All ways will be nice: configs, CLI, GUI - anything.
5 Answers
Tested using Ubuntu 16.04 LTS:
For WPS Push-button mode:
sudo wpa_cli wps_pbc
You can push the WPS button before or after this command, but you have two minutes to have the button pushed and this command ran or you'll have to do it all over again.
For WPS Pin mode:
sudo wpa_cli wps_pin any <the pin>
http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/external/bsd/wpa/dist/wpa_supplicant/README-WPS
-
Doesn't work for me with Mint 17.3 and TP-Link TL-WR1043ND. Maybe "QSS" not the same as "WPS".– MichaelMay 10, 2016 at 17:26
-
You are correct, QSS is not the same as WPS.... But this question is about WPS, so.... May 14, 2016 at 3:55
-
Doesn't work for me on Xenial.
wpa_cli status
returnswpa_state=COMPLETED
(among other data), but I'm no more connected to the network than I was before. A couple of minutes later, I'm back towpa_state=INACTIVE
as a response. May 16, 2017 at 20:04 -
2This worked, however I also had to manually start dhcpcd (
sudo dhcpcd
) and the network icon in my taskbar showed no connection even though I could load webpages.– ShelvacuSep 2, 2017 at 4:59
Solution from [email protected] http://code.google.com/p/reaver-wps/issues/detail?id=203
Check your interface with this command
sudo wpa_cli wps_pin any
You will get "Selected interface 'your interface' " when you see Your_Interface in the next commands know that you have to replace it with the Interface that you got from this command...
Stop the Network-Manager
Using Upstart
sudo stop network-manager
Using Systemd
sudo systemctl stop NetworkManager.service
Set yourself up a very basic
wpa_supplicant.conf
in/etc/wpa_supplicant.conf
. This command will overwrite any pre-exsiting wpa_supplicant.conf file!:echo -e "ctrl_interface=/var/run/wpa_supplicant\nctrl_interface_group=0\nupdate_config=1" | sudo tee /etc/wpa_supplicant.conf
Start
wpa_supplicant
in daemon mode:sudo wpa_supplicant -B -Dwext -i**your_interface** -c/etc/wpa_supplicant.conf
Run
sudo wpa_cli
. This will start a interactive wpa_cli session.
Verify that it's working by issuing command
status
. You should seewpa_state=INACTIVE
Issue
scan
to scan for existing access-points.Issue
scan_result
after a few seconds to show the results from your scanAdd our BSSID and PIN:
wps_reg xx:xx:xx:xx:xx:xx 12345678
Where
xx:xx:xx:xx:xx:xx
is your BSSID from your scan results. You should see an "OK". Wait a few more seconds aswpa_supplicant
picks up the BSSID and tries to associate and perform key negotiation. What you want to see isCTRL-EVENT-CONNECTED
, which will indicate that the PIN was accepted and that you're now associated.Type the command
save
, which should output another "OK". This will update thewpa_supplicant.conf
file, as specified from the command line, with a static configuration for this new network.Now exit
wpa_cli
by hitting Ctrl D
Run
sudo dhclient **your_interface**
to get IP from the AP (assuming DHCPd were enabled).Verify with
cat /etc/wpa_supplicant.conf
your newly updated config-file.
If all went well, you should have a line under this new network titled psk
.
Good luck!
-
1Solution doesn't work.
ioctl[SIOCSIWENCODEEXT]: Invalid argument
using Ubuntu 12 LTS. Is there support in NM?– UraMar 31, 2013 at 22:48 -
@Dejan I got that warning as well in Ubuntu 12 LTS -- solution still worked though. Dec 30, 2013 at 19:21
-
@Seth Excuse me, as you know there is no wpa_supplicant.conf in Ubuntu 14.04. Could you please help me? Finally after getting a lots of error, in
sudo wpa_cli status
I gotFailed to connect to non-global ctrl_ifname: (null) error: No such file or directory
error. Dec 4, 2015 at 13:15 -
@Daniyal You should ask a new question, comments aren't a good place for third party debugging :)– SethDec 4, 2015 at 16:14
-
1@Seth Thanks, could you please take a look at askubuntu.com/questions/705937/… Dec 4, 2015 at 16:34
Connect through WPS on a windows setup, where it works out of the box.
Then open up the network settings on that setup, where it allows you to display the network password that was exchanged through WPS.
Copy that password to your ubuntu setup.
-
3Don't know why this is being downvoted - it's a practical solution to the main reason this question is useful - that is "I don't know the WIFI password, but I have WPS access, how can I connect?" +1 This also work on android, with a root-mode file explorer, you can check the passwords in
/data/misc/wifi/wpa_supplicant.conf
. May 28, 2015 at 17:50 -
3Ah, maybe the downvotes were for the comment about ubuntu being frustrating. Here is the relevant bug report - go an subscribe to that, if you want WPS support. May 28, 2015 at 17:53
-
Thanks for the Android tip, @naught101; worked beautifully from my rooted Nexus 7's terminal! :-) Sep 21, 2015 at 12:48
-
2@neverMind9: No worries. You downvote it because it's not the "correct" way, and I'll upvote it because it works. Oct 23, 2018 at 22:44
-
1@neverMind9 If you wish a working WPS, talk to the Ubuntu team. This site is for finding solutions and this answer is a working solution. Apr 19, 2019 at 8:33
I found that I needed instructions from multiple posts above to complete the task as Xubuntu did not have a WPS of any kind that I could find.
Steps 1-3 from https://askubuntu.com/a/170799 .
This one to enable the actual push: https://askubuntu.com/a/769600 .
In this case i used the push button not the pin.And finish with a dhclient.
Linking a script to show how it works with comments. I hope it's ok to do this.
#!/bin/sh
# tadaen sylvermane | jason gibson
# connect to wps capable router via push button. yes we need a gui solution
# but this does it via terminal window. just run the script.
# https://askubuntu.com/questions/120367/how-to-connect-to-wi-fi-ap-through-wps
WIFIIF=$(grep wpa /proc/net/unix | cut -d \/ -f 4)
WPACONF=/etc/wpa_supplicant.conf
# steps 1-3 https://askubuntu.com/a/170799
if [ "$USER" = root ] ; then
# stop NetworkManager for this session
systemctl stop NetworkManager
# create wpa supplicant base file
if [ ! -f "$WPACONF" ] ; then
echo "ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1" > "$WPACONF"
fi
# start wpa_supplicant daemon
wpa_supplicant -B -Dwext -i"$WIFIIF" -c "$WPACONF"
# https://askubuntu.com/a/769600
wpa_cli wps_pbc
# go push the button!
echo "push the wps button on the router now!"
read -p "after wps button pushed type yes to connect or no to cancel -> " \
yesno
case "$yesno" in
Y|y|yes|Yes|YES)
dhclient
wait
ping -c 1 8.8.8.8 && echo "connected!" && exit 0
;;
*)
# cancel all above changes #
rm "$WPACONF"
kill $(ps aux | grep "$WIFIIF" | grep root | awk '{print $2}')
systemctl start NetworkManager
exit 0
;;
esac
else
echo "must run as root or with sudo"
exit 1
fi
# end script #
-
Welcome to Ask Ubuntu! I think is totally ok to link a script, but maybe You could just copy-pase it here? Please use "```" (triple backtick, without quote symbols) at the lines before and after the code to keep a correct formatting, Thank You in advance and for the answer!– kcprAug 5, 2021 at 23:31
-
1i'll try that. im away from home on my laptop. tried the typical [code] tags bug didn't work. when i get home tomorrow evening ill make a direct post of the script. Aug 6, 2021 at 2:21
if you don't want to type the password you should click on the wifi indicator select the wifi network and then when the enter password screen appears push the wps button in the wifi ap this will automatically connect you without password. It worked in my ubuntu 18 and 20 machine.
wpa_cli
forums.linuxmint.com/viewtopic.php?t=192554