In this tutorial you'll set up a Raspberry Pi in a headless configuration. Meaning you'll be able to use it without its own keyboard, mouse, or monitor. You will connect to it either over WiFi or using an ethernet cable. Using you Raspberry Pi in a headless configuration is handy if you don't have room to setup another monitor and keyboard or your Raspberry Pi is somewhere hard to reach. You will be connecting to your Raspberry Pi using Secure Shell or SSH for short, SSH allows your connect and control other devices as long as they on the same network. You can read more about SSH on the Raspberry Pi here.
- Raspberry Pi
- Power cable
- Ethernet cable
- Ethernet adapter (if you computer doesn't have a built in port)
- Micro SD card
- Micro SD card reader
In this section you'll prepare a new SD card to use in your Raspberry Pi.
- Create your SD Card using Raspberry Pi Imager
- Select CHOOSE OS
- Select Raspberry Pi OS
- Select the SD card you want to image and press
WRITE
Note: this may take a few minutes to run
- Once the imager is done, eject and reinsert SD Card. Open the SD card directory in file explorer.
- Copy the ssh file from this repository on to the SD Card. If you your Raspberry Pi supports WiFi (Pi0/3/4) also copy the wpa_supplicant.conf and follow the steps below (you can also skip these steps and step WiFi later):
- Open wpa_supplicant.conf in a text editor
- Enter your country as a 2 letter abbreviation. If you're not sure what your country's abbreviation is you can set it to US, and update it later.
- Add the Network name and password in to the file
- Save and close the file
What are these files? ssh is an empty file that lets Raspberry Pi OS know to enable Secured Socket Host when first initializing the operating system. wpa_supplicant.conf allows you to enter your WiFi credentials at setup.
In the following section you'll connect to Raspberry Pi from you computer, change the password, and update the operating system.
- (Skip this step if you're connected to WiFi) Connect your Raspberry Pi to your computer with an ethernet cable
- Insert the Micro SD card into the SD card slot on the Raspberry Pi
- Connect your Raspberry Pi to a power source
- On your computer open Command Prompt (windows) or Terminal (mac)
- Type
ssh [email protected] -o UserKnownHostsFile=/dev/null. Note: we use the UserKnownHostsFile=/dev/null option here in order to not save the hostname to our ssh Known Host record. We only do this the first time we connect because we're going to change the Host Name.If you already have a Pi using the hostname
raspberrypi.localyou will need to connect using the Pi's IP address. Use the commandssh pi@<IP_Address>, where<IP_Address>is the IP address, for example192.168.0.2. You can find the IP address either using your routers management software, or by disconnecting the other Raspberry Pi from the network and runningping raspberrypi.local -4in command prompt. - You will be asked if you trust this source, say yes

- You will be prompted for a password, enter
raspberry

- Now that you're in your Raspberry Pi you'll want to change the password. Type
sudo raspi-configto open the configuration tool - Select option 1 Change User Password

- Enter a new password
- Next you'll want to change the host name. Select option 2 Network Options. Then select option N1 Hostname. If you don't change the host name you will run into problems if you try to setup another Raspberry Pi in a headless configuration.

- Make sure to choose a unique name for each device you set up.

- Next choose option 8 Update
- After the update completes, choose Finish. Your Raspberry Pi may automatically disconnect if it does not type
sudo reboot. - In command prompt type
ssh pi@<YOUR-DEVICE-NAME>.local - Enter your new password, now you're back in your Raspberry Pi's command line interface.
- Optional: It's good practice to update the operating system and any packages that are installed the first time you run it. To do that type
sudo apt-get updateandsudo apt-get upgrade. This may take a few minutes to run.
If you are comfortable working in Linux command line you can stop here. If you prefer to work in a desktop environment the next section will walk you through setting up Remote Desktop.
- If you're using Windows you'll need to install Remote Desktop to do that type
sudo apt-get install xrdpthis will take a few minutes. - Open remote Desktop on you computer, and enter the hostname you gave your Raspberry Pi

- Enter your user name and password.

- You're all set, now you have access to your Raspberry Pi desktop.

- If you are using a Mac RealVNC is already installed, but you'll have to change the screen resolution to anything besides the default. To do that type
sudo raspi-config - Select option 7 Advanced Options
- Select option A5 Screen Resolution
- Choose any resolution other than the default

- Your Raspberry Pi will reboot
- On your Mac download RealVNC viewer
- Read through the EULA and the privacy notices before accepting. You will also be asked to allow access to the accessibility features of your computer.
- In RealVNC enter the hostname you gave your device

- Log in with your user name and password.

- You can now access the Raspberry Pi's desktop from your Mac
