Network configuration tricks
Setting up wifi config: /etc/wpa_supplicant/wpa_supplicant.conf
Example to set up multiple wifi credentials:
country=<country code>
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="SSID-wifi-1"
psk="password-wifi-1"
key_mgmt=WPA-PSK
}
network={
ssid="SSID-wifi-2"
psk="password-wifi-2"
key_mgmt=WPA-PSK
}
Configuring static IP address: /etc/dhcpcd.conf
Example to configure multiple static IP addresses for different WiFi’s (https://raspberrypi.stackexchange.com/a/101175)
interface wlan0
ssid SSID-wifi-1
static ip_address=192.168.42.42
static routers=192.168.42.1
ssid SSID-wifi-2
static ip_address=192.168.0.100
static routers=192.168.0.1
static domain_name_servers=8.8.8.8
Run scripts/programs automatically at startup
Use raspi-config to set boot option to “console auto login”. Add your script to the end of ~/.bashrc
Advantages of this method: The script/program runs in the foreground. It is therefore easy to kill it by plugging in a keyboard and hitting Ctrl-C. This is particularly important for scripts launching raspivid, which hides the console when it previews the live video in the framebuffer (would make it difficult to enter commands blindly to terminate it). Caution, however, as the script is also launched for each SSH session. Similarly though, Ctrl-C will terminate it and drop the user into bash.
SSL certificate problems
Sometimes there are errors complaining about invalid SSL certificates, e.g. when running wget, or also python pip. This is a red herring most of the time – the cause for the problem is often that the time/date is not set correctly. For some reason, NTP doesn’t work any more on RPi3 with stock Raspian. Until this is fixed, here’s a handy script, that can be added to .bashrc and auto-launched:
sudo date -s "$(wget -qSO- --max-redirect=0 google.com 2>&1 | grep Date: | cut -d' ' -f5-8)Z"