I have a raspberry pi 0
, but don't have/don't want to connect to a screen/hdmi/SSH
. I can plug my pi's sdcard
into my laptop and access the raspbian
installation files, so is there a way I can instruct my Raspberry-pi 0
to connect to a specific wifi using a specific password by adding some files to the sdcard/OS on my laptop and make it so when it boots up it connects to that specific wifi?

- 99
- 1
-
2Possible duplicate of How can you setup wifi without a usb hub on a Pi Zero? – Dmitry Grigoryev Jul 01 '19 at 09:21
3 Answers
The simplest method is to create a file in the boot partition, i.e. the only partition a windows laptop can read anyway, as follows
The filename is wpa_supplicant.conf
and it MUST be in linux end-of-line format (notepad++ lets you do this, recommended)
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=xx
network={
ssid="your ssid"
psk="your password"
key_mgmt=WPA-PSK
scan_ssid=1
}
where xx is your ISO/IEC alpha2 code
"country code" - which, if your profile is correct, would be KR
As opposed to the other answer, no need to "generate the psk" you can simply put the password in quotes instead
On booting, this file will be copied to the correct place and used insteda of whatever is there already
Note: I'm assuming you are running at least raspbian stretch, not sure if earlier raspbian worked like this

- 2,415
- 1
- 13
- 14
Because you don't tell us what operating system do you use on your laptop, here is a bit more generic solution to modify wpa_supplicant.conf
. If you use MS Window$ or Mac OS X you are not able to read the root partition on the SD Card that contains /etc/wpa_supplicant/wpa_supplicant.conf
. But the boot partition (on a running RasPi mounted at /boot
) can be used on most other computer. It is the partition formated as fat32 and contains the kernel and firmware to boot the RasPi. You should find kernel.img
and start.elf
and other drivers on it. You can put a file wpa_supplicant.conf
on it. On boot up this file is moved (it disappears) and overwrite /etc/wpa_supplicant/wpa_supplicant.conf
.
This way you can configure the wifi client as you like, for example with modified or additional network blocks in wpa_supplicant.conf.

- 42,107
- 20
- 85
- 197
-
@JaromandaX Just see that you have made nearly the same answer :) Anyway - I will not purge mine because there are some additional info. – Ingo Jul 01 '19 at 09:46
assuming your Pi is already correctly set up for networking and wifi, you can modify (or create if not present) a file /etc/wpa_supplicant/wpa_supplicant.conf
with a content like follow:
country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="xxxxxx"
psk=xxxxxxxxxx
}
Where ssid is the SSID (name) of your wifi network and psk is a pre-shared key.
To generate the psk you can use the wpa_passphrase
utility (on any linux computer) like follow:
$ wpa_passphrase yournetwork yournetworkkey
network={
ssid="yournetwork"
#psk="yournetworkkey"
psk=70989c22e6ea590184d5def213278204e50a7eb52a00a122f430083b882deadc
}
and it will generate the network
block for you that you can add to your config file.

- 174
- 5
-
you may want to mention that
country=US
is only for Merkins in the Unarted States of Trumpmerica ... also, your answer makes another assumption, that the laptop can read EXT4 filesystem – Jaromanda X Jul 01 '19 at 09:18