Skip to content

Instantly share code, notes, and snippets.

@alghanmi
Last active January 28, 2021 00:47
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 13 You must be signed in to fork a gist
  • Save alghanmi/4de45337ca517ebe3a56 to your computer and use it in GitHub Desktop.
Save alghanmi/4de45337ca517ebe3a56 to your computer and use it in GitHub Desktop.
WPS on OpenWRT -- Enabling Wi-Fi Protected Setup on OpenWRT
##
## WPS on OpenWRT
## This script enables Wi-Fi Protected Setup on OpenWRT.
##
## Resources
## http://wiki.openwrt.org/doc/uci/wireless#wps.options
##
#Install the full wpad package
opkg update
opkg remove wpad-mini
opkg install wpad hostapd-utils
#Enable WPS on the Wifi network interface.
# Notes:
# * The network interface should be configured to support WPA2-PSK
# * This script assumes the last interface is the one used for WPS, hence using @wifi-iface[-1]
# * You can view all the wireless interfaces by issuing the following command and getting the index of the correct one
# uci show wireless
uci set wireless.@wifi-iface[-1].wps_pushbutton=1
#The following are all optional
uci set wireless.@wifi-iface[-1].wps_device_name="OpenWRT AP"
uci set wireless.@wifi-iface[-1].wps_manufacturer="openwrt.org"
##
## Save Changes & Reboot
##
uci commit
#reboot # based on comments, reboot is no longer required.
##
## Run WPS
##
hostapd_cli -p /var/run/hostapd-phy0 wps_pbc
@alghanmi
Copy link
Author

Thanks! I updated the script

@NovaViper
Copy link

@etskinner:
you may try
hostapd_cli -i wlan0 wps_pbc
and
hostapd_cli -i wlan0 wps_get_status

I'm having the same issue on my TPLink Archer 1750 A7, neither of those commands work for me, I just get "UNKNOWN COMMAND" when I run them

@proycon
Copy link

proycon commented Jul 13, 2020

@NovaViper First restart the radio device or reboot, that should fix it. I had the same issue

@JardaG
Copy link

JardaG commented Aug 17, 2020

What do you think about adding this line?
opkg remove wpad-basic
I have OpenWrt 19.07 @ TP-Link Archer C7 v2 and wpad-mini is not installed there, but wpad-basic is present.

@amuuza
Copy link

amuuza commented Jan 8, 2021

I also have OpenWRT 19.07 and I cannot make it work.

 -----------------------------------------------------
 OpenWrt 19.07.5, r11257-5090152ae3
 -----------------------------------------------------
root@OpenWrt:~# hostapd_cli -p /var/run/hostapd-phy0 wps_pbc
Failed to connect to hostapd - wpa_ctrl_open: No such file or directory
root@OpenWrt:~# 
root@OpenWrt:~# hostapd_cli -p /var/run/hostapd wps_pbc
Selected interface 'wlan0'
UNKNOWN COMMAND
root@OpenWrt:~# 

What could I do?
Did anyone manage to make it work with 19.07?

@JardaG
Copy link

JardaG commented Jan 12, 2021

I also have OpenWRT 19.07 and I cannot make it work.

 -----------------------------------------------------
 OpenWrt 19.07.5, r11257-5090152ae3
 -----------------------------------------------------
root@OpenWrt:~# hostapd_cli -p /var/run/hostapd-phy0 wps_pbc
Failed to connect to hostapd - wpa_ctrl_open: No such file or directory
root@OpenWrt:~# 
root@OpenWrt:~# hostapd_cli -p /var/run/hostapd wps_pbc
Selected interface 'wlan0'
UNKNOWN COMMAND
root@OpenWrt:~# 

What could I do?
Did anyone manage to make it work with 19.07?

If you have the wpad-mini or wpad-basic package installed, uninstall them and install only hostapd-utils, I think it helped me then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment