-
Notifications
You must be signed in to change notification settings - Fork 3
Initial Raspberry Pi Setup
Tristan Keen edited this page Feb 6, 2021
·
4 revisions
If you want to access & configure the Raspberry Pi via SSH rather than connecting a monitor & keyboard (i.e. "headless"), you can enable the SSH Server & copy in your WiFi SSID and password so it connects to your network automatically.
- Create a SD card with your boot image, e.g. using the Imager. I suggest the choosing Raspbian Pi OS Lite if you don't need a desktop.
- Copy the two non-readme files,
sshandwpa_supplicant.conffrom the setup/headless folder to the "boot" partition of the SD card you can see from Windows. Yes thesshfile is meant to be empty & don't add any file extensions to either. - Edit the
wpa_supplicant.conffile now on the SD card to fill in your WiFi SSID and password or encrypted PSK. Use a non-formatting, non-renaming editor like Notepad++ or VSCode. - Eject the SD card, plug it into the RPi and let it boot - it can take 5 mins for the initial boot to proceed enough for
ssh pi@raspberrypito work, with the standard default password ofraspberry.
NOTE
If you don't yet have a SSH key, see the GitHub guide.
I strongly recommend switching from passwords to authentication via your local SSH key, usually stored on your laptop at ~/.ssh/id_rsa (private key) and ~/.ssh/id_rsa.pub (public key):
# Copy your SSH public key from laptop to RPi for future authentication
# (you'll need to type in the RPi's, probably default, password)
ssh-copy-id pi@raspberrypi
# Check it works
ssh pi@raspberrypi
# <on the RPi> Update the standard password, disable password authentication, and rename the host
passwd
sudo sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
# Finally, rename the RPi from the generic "raspberrypi" to something specific (change `newhostname`!) and reboot it
sudo raspi-config nonint do_hostname newhostname
sudo reboot
# Wait a minute and then try reconnecting, this time no need to type a password!
ssh pi@newhostname