How to connect to WiFi via WPS in Ubuntu: A step-by-step guide

Modern operating systems based on the Linux kernel, such as Ubuntu, often provide users with extensive customization options, but some features familiar to Windows owners may be hidden or require manual activation. One such feature is connecting to a wireless network using technology WPS (Wi-Fi Protected Setup). While the default Ubuntu graphical interface may not display the quick connect button, the technical ability to implement this action through the terminal remains fully functional and stable.

The main difficulty is that the standard network manager NetworkManager A router doesn't always have a built-in GUI for entering the WPS PIN, especially in recent versions of the distribution. However, using command-line utilities, you can initiate the pairing process with the router in seconds. This is especially useful when the network password is too complex to enter manually or when you need to quickly grant access to guests without revealing the main security key.

In this article, we'll detail the process of installing the necessary packages, finding your network card's PIN, and successfully connecting to an access point. We'll also examine the utility's operation. wps-cli and alternative methods that will help you if standard solutions fail. Understanding these processes will give you complete control over your system's network connections.

Checking hardware and driver compatibility

Before installing additional software, you need to ensure that your wireless adapter is physically capable of supporting the WPS protocol. Not all Wi-Fi modules, especially budget USB dongles or older integrated cards, have hardware or software support for this feature in the Linux environment. The device driver must correctly interact with the system calls used by the utility. wpa_supplicant.

To begin diagnostics, you will need to open a terminal and run a command to view a list of network interfaces. Enter ip link or more detailed iwconfigto see the name of your wireless device, which is usually labeled as wlan0, wlp2s0 or similar. If the interface is displayed as DOWN, it must be activated with the command sudo ip link set dev wlan0 up.

⚠️ Attention: Some proprietary Broadcom drivers may not support WPS in Linux without additional configuration or kernel module replacement. If the utility returns a support error, check the documentation for your specific chipset model.

Next, you should check whether the system sees the access point itself and whether it supports WPS. Use the command iwlist wlan0 scanning | grep -i wps to search for WPS announcements on the air. If you see lines containing WPS or Wi-Fi Protected SetupThis is a good sign, indicating that the router is broadcasting the necessary information. The absence of such lines may indicate that the function is disabled in the router's settings.

It's also important to note that modern WPA3 security standards often limit or completely prohibit the use of classic WPS for security reasons. If your network is operating in WPA3-Personal, WPS connection attempts may fail and you will have to use the traditional password entry.

Installing the required packages and utilities

In Debian-based distributions, which include Ubuntu, the main tool for managing wireless connections is the package wpa_supplicantHowever, to work conveniently with WPS via the command line, an additional package known as wps-cli or using built-in capabilities wpa_cliThese tools may not be installed by default in Ubuntu repositories on minimalist builds.

To install the basic toolchain, open a terminal and update your package lists to avoid dependency errors. Then install the core wireless network management package. The command will look like this:

sudo apt update

sudo apt install wpasupplicant wireless-tools

If your Ubuntu version's repositories don't have a pre-built binary file wps-cli, you may need to compile it from source or use an alternative method via wpa_cli, which we'll discuss below. In some cases, users successfully utilize wrapper scripts available on the platform. GitHub, but for system stability it is better to rely on official repositories or verified PPA.

📊 What type of Wi-Fi adapter do you have?
Built into the motherboard
USB whistle
PCI-E card
I don't know / I need to check

After installing the packages, it is recommended to restart the network service or simply reconnect the adapter for the changes to take effect. Make sure you have superuser (sudo) privileges, as without them, manipulation of network interfaces will be blocked by the security system. Ubuntu.

Finding the PIN code for a wireless adapter

A key step in the connection process is obtaining your device's unique identifier—the PIN. Unlike the network password, which you enter on the router, we need the internal PIN of your Wi-Fi card, which it communicates to the router when requesting a connection. Without this PIN, the router will not be able to identify your device in WPS mode.

To obtain this code, use the utility wps-cli in conjunction with the interface wpa_supplicantFirst, you need to start the background process. wpa_supplicant for your interface if it is not already running. Then, using the command wps-cli, you can request the generation or display of the current PIN code. A command of the form wps-cli wlan0 pin, Where wlan0 — the name of your interface.

If the standard utility does not provide a PIN code, you can try using wpa_cli in interactive mode. Run sudo wpa_cli, then enter the command wps_pin any to generate time code or wps_get_pin to obtain a constant. Write down the resulting value, as you will need it in the next step.

Team Description of action Necessary rights
wps-cli wlan0 pin Display the current adapter PIN sudo
wpa_cli wps_pin any Generating a new temporary PIN sudo
iwlist wlan0 scan Scanning available networks Ordinary
nmcli dev wifi List of networks via NetworkManager Ordinary

It's worth noting that some adapters may have a fixed PIN code set by the manufacturer, while others generate it dynamically each time the service is started. Understanding your adapter type (fixed or dynamic PIN) is critical for setting up automatic connections in the future.

Connection process via terminal (wps-cli)

Once you've obtained your adapter's PIN and verified that the target network is visible and supports WPS, you can proceed to the actual connection. This step requires careful attention, as the commands must be entered in the correct order. The process is initiated by sending a request to the router using the previously obtained identifier.

Using the utility wps-cli, issue the connect command, specifying the interface and, if necessary, the BSSID (MAC address) of the access point. The syntax is typically wps-cli wlan0 start [BSSID]If you have multiple networks, specifying the BSSID will help you avoid connecting to a neighboring router with a similar name.

☑️ Ready to connect

Completed: 0 / 4

When the command is executed, the WPS indicator on the router typically lights up, indicating a connection attempt. You have a limited time (usually 2 minutes) to confirm the connection if the router requires a physical press of a button, or the system will do it automatically if the mode is initiated via software.

⚠️ Attention: If you see the error message "WPS overlap detected," this means another client is already attempting to connect to the router via WPS. Wait a minute and try again.

If successful, the terminal will display a message that the connection has been established, and the network manager Ubuntu should receive an IP address via DHCP. You can check the connection status with the command ip addr show wlan0, where in the line inet The issued address should be displayed.

Alternative method via wpa_cli

If the utility wps-cli is not available or does not work correctly with your driver, you can use a lower-level tool wpa_cliThis method requires more manual steps, but gives you complete control over the process and often works where other methods fail. It's especially useful for older or more exotic Wi-Fi adapter models.

First, run wpa_cli in interactive mode with superuser rights: sudo wpa_cli -i wlan0Inside the shell, run the command wps_ap_pin or wps_pbc (Push Button Configuration) if the router supports push-button connection without entering a PIN. PBC mode is often more convenient because it doesn't require entering a digital code.

To connect via PBC, follow these steps:

  • 🔘 Press the WPS button on the router's physical body or activate it in the web interface.
  • 💻 In the terminal, enter wps_pbc and press Enter.
  • ⏳ Wait for a message WPS-SUCCESS in the log.
What to do if wpa_cli doesn't see the interface?

If you receive an error when starting wpa_cli, make sure the wpa_supplicant service is running. Also, check if the NetworkManager service is blocking the interface. Temporarily stop it with the command sudo systemctl stop NetworkManager, but remember that doing so will result in you losing graphical network management until you reboot or manually start the service.

After successfully completing the WPS process, be sure to save the configuration so that the system remembers the network. In interactive mode wpa_cli this is done by a team save_configThis will write the network settings to the configuration file. /etc/wpa_supplicant/wpa_supplicant.conf.

Setting up automatic connection and security

After a successful one-time connection, it's important to configure the system to connect to this network automatically in the future. In Ubuntu, this is handled by NetworkManagerIf you used console utilities, the network profile may not have been created automatically in the graphical interface, and you'll need to add it manually or export it.

You can create the configuration file manually or use nmcli to add a connection using the received security keys. However, since WPS generates a standard WPA password, you can simply add the network through the graphical interface by entering the password if it was displayed during the WPS session, or rely on a saved profile. wpa_supplicant.

From a security standpoint, using WPS carries certain risks. The protocol is susceptible to brute-force attacks, especially if a PIN code is used. Therefore, after initially setting up your home network, it is recommended to disable WPS in your router settings to prevent unauthorized access by intruders.

In corporate networks, using WPS is typically prohibited by security policies. If you're setting up a work laptop, ensure your actions comply with IT department regulations. In such cases, using certificates or complex passwords entered manually is preferable.

Troubleshooting and error resolution

Despite its apparent simplicity, connecting via WPS in Linux can encounter a number of obstacles. One of the most common issues is a conflict between NetworkManager And wpa_supplicantIf both services attempt to manage the same interface at the same time, commands may fail or be ignored.

Another common issue is connection timeouts. If the router doesn't respond within 2 minutes, the connection is aborted. This can be caused by a weak signal or channel congestion. In this case, try moving closer to the access point or rebooting the router before trying again.

  • 🚫 Error: "Interface not ready": The interface is busy with another process. Stop NetworkManager or use sudo ip link set wlan0 down and again up.
  • 🚫 Error: "Driver command failed": Your card driver doesn't support WPS. Try updating your drivers or using a USB adapter with an Atheros or Ralink chipset.
  • 🚫 Endless Waiting: Most likely, WPS mode isn't enabled on your router. Press the button on the device or enable the feature in the web interface.

⚠️ Attention: Interfaces and commands may vary depending on the Ubuntu version and the network manager installed. Always check the latest documentation for your distribution if the standard paths don't work.

If nothing helps, use logging. Run wpa_supplicant in debug mode with flag -ddto see detailed packet exchanges between the card and the router. This will help pinpoint the exact point at which the connection is failing.

Frequently Asked Questions (FAQ)

Is it possible to connect Ubuntu to WPS without a terminal?

In the standard GNOME desktop environment (the default in Ubuntu), the WPS button is often hidden or missing. However, some desktop environments, such as KDE Plasma or XFCE, may have NetworkManager plugins that add this feature to the GUI. Third-party graphical utilities also exist, but installing terminal tools is more reliable.

Does WPS work on Ubuntu with Keenetic or TP-Link routers?

Yes, the WPS protocol is a standard, and Ubuntu connects successfully to routers from all manufacturers, including Keenetic, TP-Link, ASUS, and Zyxel. The main thing is that the function is enabled on the router side, and the Wi-Fi adapter driver in Linux supports the necessary commands.

Where are saved Wi-Fi passwords stored in Ubuntu after connecting via WPS?

Passwords and network configurations are stored in system files. For NetworkManager, this is usually a directory /etc/NetworkManager/system-connections/The files are protected by root access rights, so you will need superuser rights to view them (command sudo cat).

Why does the wps-cli command return a "command not found" error?

This means the package containing the utility is not installed. It may have a different name in the Ubuntu repositories or require a package to be installed. wpagui or build from source. Try searching for the package via apt search wps or use the alternative method via wpa_cli.

Is it safe to keep WPS enabled on my router all the time?

No, this is not recommended. WPS has known vulnerabilities that make it relatively easy to brute-force the PIN and gain access to the network. It's best to enable this feature only when connecting new devices and then immediately disable it in the router settings.