Introduction: Raspberry Pi Headless Setup

About: I am a hardcore robotics and IoT enthusiast.

You will learn how to enable access to Raspberry Pi for via ssh without connecting a keyboard, mouse and monitor to it, in the so-called Headless mode.

Supplies

Before boot up your Raspberry Pi 4 Model B you need below items.

  • Laptop or standalone PC
  • A micro-SD card (minimum16GB)
  • Ethernet cable
  • Compatible power supply - you can also use a 5V 2.5A USB supply.
  • MicroSD Card ReaderCase(optional)

Step 1: Download a Raspbian Image

Download a Raspbian image file from the raspberrypi.org.

Step 2: Write Image to the MicroSD Card Using Etcher

To burn an image to the SD card you can use Etcher. Etcher is cross-platform desktop application, and works on Windows, Mac OS X, and Linux as well, and it prevents you from overwriting the system disk of your computer.

  1. Download the appropriate version of Etcher based on your OS.
  2. Insert an microSD using Card Reader into your computer.
  3. Run the Etcher you've downloaded.
  4. Flash the MicroSD card with the image using Etcher by selecting the downloaded zip file as the source.
  5. The image written to your card will be verified afterwards.

Step 3: Enable SSH

SSH is disabled by default for security reasons. To enable it you need to place an empty file named ssh in the root of the boot disk.

For MacOS and Linux :
Open terminal by navigating to Applications > Utilities > Terminal and run the following command:

touch /Volumes/boot/ssh

For Windows:
Create a file named ssh, without any extension, on the boot partition of the SD card.

Step 4: Setting Up Wireless Networking

  • Your Windows or Mac machine must be on the same WiFi network that you configured the Raspberry Pi in order to determine Raspberry PI’s IP Address.
  • Create a file in the root of boot disk called wpa_supplicant.conf and then paste the following code into it:
country=us
update_config=1
ctrl_interface=/var/run/wpa_supplicant
network={ ssid="your Wifi name" psk="password"}

Edit it by entering your actual SSID and password of your home Wifi network.

For MacOS and Linux :

  • Open terminal and run the following command:

touch /Volumes/boot/wpa_supplicant.conf

  • Edit the file that you just created using text editor and paste the text above into it.

For Windows:

  • Create a file wpa_supplicant.conf and save it.
  • Remove the SD card and then insert it into your Raspberry Pi
  • Power it up.

Step 5: Find Your Raspberry PI’s IP Address

  • Raspberry PI’s IP address can be found through the configuration web interface of your router in the section DHCP lease allocation table.
  • On your computer you can use utility like Advanced IP scanner (Windows) or IP Scaner (MacOS).
  • On your Android or iOS phone you can use Fing utility which can detect Raspberry Pi IP address.I used IP Scaner (MacOS) utility to determine my Raspberry Pi ip address.

I used IP Scaner (MacOS) utility to determine my Raspberry Pi ip address.

Step 6: SSH Into Your Pi

Connect your ethernet cable to your computer and to the Raspberry Pi.

  • The default credentials for SSH connection are:
username: pi
password: raspberry

For MacOS and Linux :

  • Open terminal and type below command:
ssh pi@your_ip_address

For Windows:

  • Download PuTTY from here - a free SSH and telnet client for Windows
  • Launch PuTTY
  • Check SSH radio button with port number 22.
  • Type the IP address of your Raspberry PI into Host Name field name
  • Click Open button
  • When you connect through SSH for the first time, you will be prompted to accept the RSA key fingerprint
<p>The authenticity of host 'Your_ip_adress (Your_ip_adress)' can't be established.</p><p>ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.</p><p>Are you sure you want to continue connecting (yes/no)?</p>
  • Type yes to continue.
  • Once you are logged into your Raspberry Pi you will be greeted with a message similar to the one below.
<p>Linux raspberrypi 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l</p><p>The programs included with the Debian GNU/Linux system are free software;</p><p>the exact distribution terms for each program are described in theindividual files in /usr/share/doc/*/copyright.Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extentpermitted by applicable law.Last login: Thu Sep 26 01:46:17 2019SSH is enabled and the default password for the 'pi' user has not been changed.This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.</p>

Step 7: Get the Latest Updates

Finally, you get the latest updates for the Pi as simply as typing:

sudo apt-get update -y
sudo apt-get upgrade -y

Once complete, you can reboot your Raspberry Pi by typing the following command.

sudo reboot

You now have a fully-configured Raspberry Pi running Raspbian.

You can run raspi-config any time you like, if you find that there are some settings that you need to change.

I hope you found this guide useful and thanks for reading. If you have any questions or feedback? Leave a comment below. Stay tuned!