How to connect to Wi-Fi AP through WPS? All ways will be nice: configs, CLI, GUI - anything.
75 Answers
Tested using Ubuntu 16.04 LTS:
For WPS Push-button mode:
sudo wpa_cli wps_pbcYou 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> 4 Solution from
Check your interface with this command
sudo wpa_cli wps_pin anyYou 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-managerUsing Systemd
sudo systemctl stop NetworkManager.serviceSet yourself up a very basic
wpa_supplicant.confin/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.confStart
wpa_supplicantin daemon mode:sudo wpa_supplicant -B -Dwext -i**your_interface** -c/etc/wpa_supplicant.confRun
sudo wpa_cli. This will start a interactive wpa_cli session.
Verify that it's working by issuing command
status. You should seewpa_state=INACTIVEIssue
scanto scan for existing access-points.Issue
scan_resultafter a few seconds to show the results from your scanAdd our BSSID and PIN:
wps_reg xx:xx:xx:xx:xx:xx 12345678Where
xx:xx:xx:xx:xx:xxis your BSSID from your scan results. You should see an "OK". Wait a few more seconds aswpa_supplicantpicks 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.conffile, as specified from the command line, with a static configuration for this new network.Now exit
wpa_cliby hitting Ctrl D
Run
sudo dhclient **your_interface**to get IP from the AP (assuming DHCPd were enabled).Verify with
cat /etc/wpa_supplicant.confyour newly updated config-file.
If all went well, you should have a line under this new network titled psk.
Good luck!
7Connect 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.
8if 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.
3I 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 .
This one to enable the actual push: .
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.
#
WIFIIF=$(grep wpa /proc/net/unix | cut -d \/ -f 4)
WPACONF=/etc/wpa_supplicant.conf
# steps 1-3
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" # 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 # 2