You can drop in a wpa_supplicant.conf file in the boot directory before installing the SD Card into the Pi. When the Pi boots up, the file /etc/wpa_supplicant/wpa_supplicant.conf will be overwritten (or maybe appended, I'm not sure) with the wpa_supplicant.conf file in the /boot/ directory.
Use the following syntax:
network={
ssid="YourNetworkSSID-1"
psk="passwordOne"
}
network={
ssid="YourNetworkSSID-2"
psk="passwordTwo"
}
The above setup works for standard WPA wifi connections. There are additional settings in the example below:
network={
ssid="myssid"
scan_ssid=1
psk="incorrect_version_of_mypassword"
mode=0
proto=WPA2
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
auth_alg=OPEN
id_str="raspi"
priority=5
}
Make sure to create the wpa_supplicant.conf file in a text editor set to UNIX encoding (if you're doing this from Windows).