33

How to connect to Wi-Fi AP through WPS? All ways will be nice: configs, CLI, GUI - anything.

Michael
  • 361
  • This question appears to be abandoned. Unaccepted answer or unanswered, could you perhaps add more detail to your question? If this question no longer applies then you can either delete it or answer it yourself if you've solved the problem. Flagged for deletion. Thanks! – Ringtail Jan 13 '13 at 03:07
  • I have no possibility to try solution for any time, but it seems good. – Michael Jan 13 '13 at 07:07
  • @user51072 Did you try it? do you have a working solution? – Ura Mar 31 '13 at 22:52
  • 1
    Its very good question but very complex answers :/ what is really interesting that on onther platforms its one click functionality... We might probably wait till there is better more stable way before accepting answer.. – Jurosh Oct 13 '18 at 18:42
  • It would be very frustrating if it lacks this basic functionality. – neverMind9 Oct 23 '18 at 17:52
  • @Jurosh One-click is what we want. Not 30 tedious steps that take minutes each time. – neverMind9 Oct 23 '18 at 17:53
  • 1
    An older answer for LinuxMint, with a detailed walkthrough of wpa_cli https://forums.linuxmint.com/viewtopic.php?t=192554 – Stavr00 Nov 26 '18 at 14:42

5 Answers5

13

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". – Michael May 10 '16 at 17:26
  • You are correct, QSS is not the same as WPS.... But this question is about WPS, so.... – Brian Foster May 14 '16 at 03:55
  • Doesn't work for me on Xenial. wpa_cli status returns wpa_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 to wpa_state=INACTIVE as a response. – Jonathan Y. May 16 '17 at 20:04
  • 2
    This 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. – Shelvacu Sep 02 '17 at 04:59
12

Solution from ryanjna...@gmail.com http://code.google.com/p/reaver-wps/issues/detail?id=203

  1. 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...

  2. Stop the Network-Manager

    Using Upstart

     sudo stop network-manager
    

    Using Systemd

     sudo systemctl stop NetworkManager.service
    
  3. 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
    
  4. Start wpa_supplicant in daemon mode:

     sudo wpa_supplicant -B -Dwext -i**your_interface** -c/etc/wpa_supplicant.conf
    
  5. Run sudo wpa_cli. This will start a interactive wpa_cli session.

  • Verify that it's working by issuing command status. You should see wpa_state=INACTIVE

  • Issue scan to scan for existing access-points.

  • Issue scan_result after a few seconds to show the results from your scan

  • Add 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 as wpa_supplicant picks up the BSSID and tries to associate and perform key negotiation. What you want to see is CTRL-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 the wpa_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

  1. Run sudo dhclient **your_interface** to get IP from the AP (assuming DHCPd were enabled).

  2. 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!

  • 1
    Solution doesn't work. ioctl[SIOCSIWENCODEEXT]: Invalid argument using Ubuntu 12 LTS. Is there support in NM? – Ura Mar 31 '13 at 22:48
  • @Dejan I got that warning as well in Ubuntu 12 LTS -- solution still worked though. – Robbie Rosati Dec 30 '13 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 got Failed to connect to non-global ctrl_ifname: (null) error: No such file or directory error. – Daniyal Javani Dec 04 '15 at 13:15
  • @Daniyal You should ask a new question, comments aren't a good place for third party debugging :) – Seth Dec 04 '15 at 16:14
  • 1
    @Seth Thanks, could you please take a look at http://askubuntu.com/questions/705937/how-to-connect-to-wifi-with-wps-pin-in-ubuntu-14-04 – Daniyal Javani Dec 04 '15 at 16:34
  • So this needs to be done each time instead of clicking twice? – neverMind9 Oct 23 '18 at 17:45
  • Isn't there any lesser tedious way? Who is ready to do this every time? – neverMind9 Oct 23 '18 at 17:57
2

If you don't want to type the password you should click on the WiFi indicator to select the WiFi network. Then, when the enter password screen appears, push the WPS button in the WiFi AP. This will automatically connect you without any password.

This works on my Ubuntu 18.04 and 20.04 machine. This method is official but undocumented.

Daniel T
  • 4,594
satyam
  • 21
2

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.

  1. Steps 1-3 from https://askubuntu.com/a/170799 .

  2. This one to enable the actual push: https://askubuntu.com/a/769600 .
    In this case i used the push button not the pin.

  3. 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

kcpr
  • 1,433
  • 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! – kcpr Aug 05 '21 at 23:31
  • 1
    i'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. – user642432 Aug 06 '21 at 02:21
2

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.

user299323
  • 87
  • 1
  • 3
    Don'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. – naught101 May 28 '15 at 17:50
  • 4
    Ah, 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. – naught101 May 28 '15 at 17:53
  • Thanks for the Android tip, @naught101; worked beautifully from my rooted Nexus 7's terminal! :-) – Tommy Stanton Sep 21 '15 at 12:48
  • 1
    It is being downvoted because we wish to use WPS immediately instead of rebooting twice. – neverMind9 Oct 23 '18 at 17:54
  • @naught101 Do not take this personally, but this really needs to be downvoted. In fact, this is the first downvote I ever placed on AskUbuntu.com. – neverMind9 Oct 23 '18 at 18:13
  • 2
    @neverMind9: No worries. You downvote it because it's not the "correct" way, and I'll upvote it because it works. – naught101 Oct 23 '18 at 22:44
  • @naught101 Gladly you're satisfied. – neverMind9 Oct 23 '18 at 23:45
  • 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. – David Balažic Apr 19 '19 at 08:33