Check the article here for a step-by-step guide:
- Insert SD card into your local machine
- Flash the SD with the appropriate OS, I recommend using raspberry-imager (you may need to reconnect your SD card after the flash process)
- When the SD write (and verification) is complete, open the terminal
touch /Volumes/boot/ssh
touch /Volumes/boot/wpa_supplicant.conf
Adjusting for your ISO 3166 alpha-2 country code, network name and network password:
Using vscode
:
code /Volumes/boot/wpa_supplicant.conf
For example:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=PT
network={
ssid="An-example-wifi"
psk="this_pw_is_fake1"
key_mgmt=WPA-PSK
priority=1
id_str="home"
}
network={
ssid="Another-wifi_name"
psk="anotherFakePassword!"
key_mgmt=WPA-PSK
priority=2
id_str="office"
}
network={
ssid="Yet_another"
psk="super_secret_password"
key_mgmt=WPA-PSK
priority=3
id_str="factory"
}
cat /Volumes/boot/wpa_supplicant.conf
- Eject your SD card
- Insert the SD card to your raspi
- Connect power source
- The LEDs should start flashing, wait for your pi to boot up
ssh pi@raspberrypi.local
Default password for pi
user is raspberry
Change default password
sudo passwd
- Type your password
- Confirm new password
You should see a message
passwd: password updated successfully
If you get an error:
passwd: Authentication token manipulation error
passwd: password unchanged
It means the filesystem was mounted as read-only, which prevents changing the password. A way to fix this issue is to remount the filesystem and then to check permissions of /etc/shadow
file.
sudo mount -rw -o remount /
or
sudo mount -o remount,rw /
sudo raspi-config
-
Advanced options
-
Select first option
A1 Expand File System
This might come in handy for two reasons:
-
Easily distinguish between devices
-
Easily ssh locally with
ssh pi@your_custom_hostname.local
sudo raspi-config
-
Network Options
-
N1 Hostname -> OK
-
Set the new hostname
sudo curl -fsSL https://raw.githubusercontent.com/JoaquimLey/raspberrypi-headless-setup/master/pi_bloat_remove.sh | sudo bash
I use ngrok to remotely ssh to my pi's. The free account is more than enough for this use case. Beware though, the port is constantly changing and the connections drop fairly frequently, can be a little bit frustrating.
- Create a free account at https://ngrok.com/
- Download ngrok for
Linux ARM
sudo wget https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm.zip
- Configure and start the service on boot using a symlink: https://github.com/JoaquimLey/ngrok-install
sudo apt-get install git
sudo apt-get update && sudo apt full-upgrade