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?


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

    ssid="your ssid"
    psk="your password"

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


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.

  • @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 1 at 9: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:

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

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

and it will generate the network block for you that you can add to your config file.

  • 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 1 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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