25

How do I configure my Raspberry Pi 3 (running Raspbian) to connect to a hidden network? I know it involves editing the /etc/network/interfaces file and the wpa_supplicant.conf file. I've followed a few other guides, but when I make these file changes and reboot, I can't even detect visible networks, as they disappear from my wifi menu. I think I'm just editing these files with incorrect configurations.

1
  • 1
    I unhid the network, connected once, then hid the network again and it connected automatically. There was a 30-45 second delay after a reboot before it connected...
    – Steve P
    Commented Apr 3, 2018 at 18:43

7 Answers 7

24

First, enter the following in the terminal:

sudo nano /etc/network/interfaces  

Edit the interfaces file to look like so, which shouldn't be too different from the default:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Next, we will edit the wpa_supplicant.conf file. Enter the following in the terminal:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Edit the settings of this configuration file to be as such:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1 
network={
        scan_ssid=1
        ssid="Your Hidden SSID"
        psk="Your SSID's Password"
        key_mgmt=WPA-PSK }

Note: You will need to change the "country" setting based on your location. Also, scan_ssid must be set to 1 to be able to detect a hidden SSID. Input your SSID name and password for your hidden network. Save these changes, reboot your raspberry pi, and then it should be automatically connected to the hidden network upon returning to the desktop.

1
  • 1
    Worked on Raspberry Pi 0 W. Thanks! Commented Sep 26, 2017 at 1:14
24

I have a Pi 3. Including or excluding country=US had no effect. editing the wpa_supplicant.conf file to look like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    scan_ssid=1
    ssid="NAME"
    psk="password"
}

removing key_mgmt=WPA-PSK and rebooting worked for me.

3
  • I struggled with this too - most of the advice is for version other than 3, or out of date. This is a year old, so you've probably fixed this but it was a top Google result so for everyone else: - for Pi 3b+ with Stretch, scan_ssid did not work for me - needed to use priority=x where 0 is the default and higher numbers are evaluated in descending order. This definitely works on a Pi 3b+ running Stretch as of this writing.
    – lonstar
    Commented Sep 17, 2018 at 14:42
  • Hm, this worked perfectly for me on a RPi3 B+; scan_ssid=1 did work and I didn't need priority
    – T3db0t
    Commented Jan 23, 2019 at 17:00
  • 2
    I have a RPi 4 Model B, and this solution worked for me.
    – arantebw
    Commented Apr 19, 2021 at 1:41
6

1. To connect to a hidden network yo need to modify only /etc/wpa_supplicant/wpa_supplicant.conf

network={
       ssid="your SSID"
       scan_ssid=1
       psk=your PSK 
}

I create this file and encrypted using wpa_passphrase "your PSK" "your SSID" command

2. /etc/network/interfaces does not need to be modify by you if you need to connect to your hidden network. When you modify wpa_supplicant.conf file in the interfaces file is created a new configuration automatically. In my case it looks like:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf  /etc/wpa_supplicant/wpa_supplicant.conf


allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf  /etc/wpa_supplicant/wpa_supplicant.conf

Be sure when you add a new network on wpa_supplicant.conf file does not exist any conflict with the IPs allowed in the /etc/dhcpch.conf file...

For more information you can check: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md

0
4

I have a Raspberry Pi 3 (Model B) running Raspbian 9 (Stretch),
this network interface configuration worked for me to connect to my routers hidden SSID (TP Link Archer 2600, secured with WPA/WPA-2 Personal).

1) /etc/network/interfaces:

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

####################################################
##### custom stuff to find hidden router SSIDs #####
####################################################
auto lo
iface lo inet loopback

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Note that I only set up loopback and wlan0 (wireless) interfaces, I didn't need the eth0 (wired connection) interface.

2) /etc/wpa_supplicant/wpa_supplicant.conf:

country=SE
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
ap_scan=1
update_config=1
network={
    scan_ssid=1
    ssid="xxx"
    psk="xxx"
}

Make sure to set up your country, ssid and psk appropriately.
ssid is the hidden SSID of your router or access point.
psk is the passphrase to connect and authenticate to the router or access point.

3) /etc/dhcpcd.conf:

I didn't have to change anything in dhcpcd.conf.

1
  • 1
    Worked for me on Pi 3 B+.
    – Amey
    Commented Nov 28, 2018 at 7:28
4

On Raspberry Pi 4, it works right after the initial configuration, but will not work after a reboot. You can fix that by editing /etc/wpa_supplicant/wpa_supplicant.conf to add scan_ssid=1 to the target network configuration. It would end up looking like this:

network={
       ssid="your SSID"
       psk="your PSK"
       ...
       scan_ssid=1
}

After a reboot, it worked like a charm.

3

Requirement of Raspberry Pi System:

  1. Raspberry Pi 3 B+ ( Raspbian Strecth Operating System )
  2. List the all available hidden wifi.

Steps to Follow

First open the terminal then type:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Add the following:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=IN
network={
        ssid="XXXXXXXX"
        priority=1
        proto=RSN
        key_mgmt=WPA-EAP
        pairwise=CCMP
        auth_alg=OPEN
        eap=PEAP
        identity="18XXXXXXXX3"
        password=hash:d7XXXXXXXXXXXxXXXxce
        phase1="peaplabel=0"
        phase2="auth=MSCHAPV2"
}

Save the file and exit the wpa_supplicant.conf. Your need to give your hidden wifi name in place of ssid, user ID in place of identity and Password need to converted into hash code format.

Use this command in terminal to convert your password into hash code format.

echo -n 'YOUR_REAL_PASSWORD' | iconv -t utf16le | openssl md4 > hash.txt

Next Do the following:

  1. sudo nano hash.txt
  2. Insert hash: in place of (stdin)=
  3. Copy the entire text and exit
  4. Next modify the password in wpa_supplicant.conf file and exit

Reboot the system.

Expected Output

It will connect to Hidden ssid

2

Tried all the previously changes on my Pi4, but I still had no success. Kept trying to disable/enable the network, and restarting my PI, but still not connecting.

I have eventually found the issue by accident by doing this command: iwlist wlan0 scan ssid "your ssid"

This have then activated the Pi to search and connect to the hidden network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.