33

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

7
  • 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, 2013 at 3:07
  • I have no possibility to try solution for any time, but it seems good.
    – Michael
    Jan 13, 2013 at 7:07
  • @user51072 Did you try it? do you have a working solution?
    – Ura
    Mar 31, 2013 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, 2018 at 18:42
  • 1
    An older answer for LinuxMint, with a detailed walkthrough of wpa_cli forums.linuxmint.com/viewtopic.php?t=192554
    – Stavr00
    Nov 26, 2018 at 14:42

5 Answers 5

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

4
  • Doesn't work for me with Mint 17.3 and TP-Link TL-WR1043ND. Maybe "QSS" not the same as "WPS".
    – Michael
    May 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 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. May 16, 2017 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 2, 2017 at 4:59
12

Solution from [email protected] 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!

7
  • 1
    Solution doesn't work. ioctl[SIOCSIWENCODEEXT]: Invalid argument using Ubuntu 12 LTS. Is there support in NM?
    – Ura
    Mar 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 got Failed 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 :)
    – Seth
    Dec 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
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.

8
  • 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, 2015 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, 2015 at 17:53
  • 1
    It is being downvoted because we wish to use WPS immediately instead of rebooting twice.
    – neverMind9
    Oct 23, 2018 at 17:54
  • 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, 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
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 #
2
  • 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 5, 2021 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 6, 2021 at 2:21
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.

3
  • In what setup have you tested this solution ?
    – breversa
    Aug 15, 2020 at 18:40
  • 1
    Works in Ubuntu 20.04. It even says you can press the WPS button of the AP in the "Enter network password" window.
    – Andrei B
    Nov 29, 2020 at 3:04
  • Tested in Ubuntu 18.04 LTS. The password dialog doesn't say a thing about WPS but it worked. Thank you!
    – rpet
    Apr 16, 2021 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .