21

I am trying to headless setup a Raspberry Pi Zero W.

I have added the wpa_supplicant.conf files as suggested.

network={
    ssid="My WiFi 2.4"
    psk="mypassword123"
    key_mgmt=WPA-PSK
}

I have also created an empty ssh file.

However, the raspberry pi never shows up on my network and I cannot ssh into it. When I plug it back into my laptop, the wpa file and ssh file are deleted as well.

Any reason why?

2
  • 3
    Raspbian is doing what it claims; setting up ssh and copying wpa_supplicant.conf to its normal location, then deleting the files on /boot. Your problem is elsewhere
    – Milliways
    Commented Jun 22, 2017 at 4:59
  • 1
    Milliways 6 is correct. As to your other problem, it may be the same as mine: raspberrypi.stackexchange.com/questions/68809 but I only got as far as I did by mounting the sdcard Linux partition on a Linux PC and inspecting the /var/log/syslog contents after a failure. Commented Jun 22, 2017 at 11:16

5 Answers 5

14

The removal of the ssh and wpa_supplicant.conf files on boot is normal. Once the RPi boots, everything should be persistent and the network and ssh available on subsequent boots. If you want to keep copies "just in case", you can create a .zip archive of those files in /boot and it will not be removed.

As to your wireless network not being recognized, it sounds like you're using raspbian stretch. Try adding the follwing lines to the top of your wpa_supplicant.conf:

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

Change US to your 2 character country code. From what I've read, the ctrl_interface line is the real trick, but the others are recommended.

1
  • /boot/ssh is removed by /etc/systemd/system/multi-user.target.wants/sshswitch.service with a ExecStart=/bin/sh -c "systemctl enable --now ssh && rm -f /boot/ssh /boot/ssh.txt" command. And /usr/lib/raspberrypi-net-mods/wpa_copy moves /boot/wpa_supplicant.conf
    – Dave X
    Commented Oct 6, 2023 at 18:51
3

I found the answer for my WiFi issues here:

Step 1: Create wpa_supplicant.conf

Step 2:

If using Windows you need to make sure the text file uses Linux/Unix style line breaks. I use Notepad++ (it’s free!) and this is easy to do using “Edit” > “EOL Conversion” > “UNIX/OSX Format”. “UNIX” is then shown in the status bar.

Step 3:

country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant

network={
 scan_ssid=1
 ssid="MyNetworkSSID"
 psk="Pa55w0rd1234"
}
1

My issue was that I had two different networks, one on 2.4GHz and one on 5GHz, each with a different name:

ME_24 ME_5

Apparently the Pi could only connect to the 2.4GHz band. Once I specified the correct ssid:

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

network={
    ssid="ME_24"
    psk="pwd"
}

It was detected and ssh worked as well.

2
  • If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From Review
    – Milliways
    Commented Jul 28, 2019 at 1:25
  • 2
    @Milliways - it's not a new question just a similar issue to "the raspberry pi never shows up on my network and I cannot ssh into it".
    – Ko Ga
    Commented Jul 28, 2019 at 11:21
0

I'm using PiAware image 3.5.0 on a Pi Zero.

The /boot/ssh file behavior is indeed as Milliways said. To get your credentials to survive a reboot, use piaware-config to set its wireless-ssid and wireless-password entries, or use nano to edit /boot/piaware-config.txt. On my system, the file /etc/wpa_supplicant/wpa-roam.conf (not wpa_supplicant.conf) is regenerated at boot time with the network settings in piaware-config.txt.

Check the wpa-roam.conf file. If it has the correct credentials, for some reason it's probably not finding the SSID. It only looks on the 2.4G frequencies, not on 5G. If the credentials are wrong, you can change them in wpa-roam.conf and test your changes using "ifdown -v wlan0" to make sure wlan0 is down, and then "ifup -v wlan0" to try creating the connection. The -v will give you verbose output, which may help you troubleshoot the problem. Once you get it working, copy the working SSID and psk settings to the piaware-config.txt file so you don't lose them when wpa-roam.conf is overwritten at the next reboot.

Hope this helps.

0

Had the same problem. I was connecting Pi to my mobile hotspot. No hope. Renamed the hotspot and removed all the spaces, it connected! I used a 2.4ghz WPA2-PSK connection. Hope that helps!

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.