Set up raspberry pi headless: How to setup your Raspberry Pi, Headless!

Headless Raspberry Pi Setup — Pi My Life Up

In this guide, we will be showing you how to set up a headless Raspberry Pi.

A Raspberry Pi is considered headless when you have no monitor or keyboard connected to it.

A headless Raspberry Pi can be useful for any situation where you don’t want or need access to a monitor and keyboard. For example, the Plex Media Server, NAS Server, or Transmission projects don’t need a monitor to be able to function.

Usually, setting up a device without a monitor or keyboard can make things a little complicated. Luckily for us, there is a couple of things we can do to reduce that.

The Raspberry Pi OS has the functionality to set up networking and SSH access without physically connecting to the device.

For this guide on setting up a headless Raspberry Pi, we recommend that you use the Lite version of the operating system. The lite version of the OS does not come with the GUI, which is unneeded in a headless setup unless you are using remote desktop software.

Once you have written the Raspberry Pi OS to your SD Card, make sure you keep it connected to your device as we will need to add some additional files to it..

Enabling SSH for your Headless Raspberry Pi

In our first section, we will show you how you can enable SSH without needing access to your Raspberry Pi’s interface.

We can do this by creating an empty file named ssh in the /boot folder of your SD Card.

Make sure when you create this file that you do not give it a file extension.

When you start up your Raspberry Pi, the operating system will find the ssh file and automatically start the process of activating SSH on your device.

The ability to enable SSH through this method was implemented in Raspberry Pi OS after they disabled SSH from being enabled on a fresh install.

Setting up Networking for a Headless Raspberry Pi

Alongside the ability to enable SSH without needing a monitor or keyboard, you can also set up your networking.

While an ethernet connection tends to work out of the box, a wireless connection will always need to be configured manually.

To set up our WiFi connection on a headless Raspberry Pi, we will need to create a file within the /boot folder.

1. First, open the boot directory for your Raspberry Pi’s SD Card.

Within this SD card, create a file called “wpa_supplicant.conf” and begin editing it in your favorite text editor.

2. Within this file, we can enter the configuration details for our network.

Before we do this, you must first work out the 2 letter ISO 3166-1 country code.

As an example of a valid country code, the code for Australia is “AU“. For the United Kingdom, this code is “GB“, and for the United States, the country code is “US“.

In addition to the country code, you must also know the SSID and the password for the WiFi network you want to connect to.

3. Once you have the required information, go ahead and enter the following text into the file.

Make sure you fill in the correct information within this file. We have highlighted the sections that need you to fill in your information.

Once you are done, you can save the file and insert the SD card into your Raspberry Pi.

4. If you are wondering how this all works, the Raspberry Pi OS detects that this file exists within the boot directory.

Once it detects the file, it copies it from the boot drive to the correct location on the root file system. It then uses these settings to start up the wireless network connection.

Setting up Additional Remote Access

Once you have SSH access to your Raspberry Pi and a network configuration, you can set up additional ways of remotely accessing your Raspberry Pi.

You can set up TeamViewer so you can access your Raspberry Pi through their servers.

Alternatively, you could set up a VNC server on your device. This software will allow you to gain access to your desktop using any VNC compatible client.

It is also possible to add support for the remote desktop protocol that Windows utilizes.

What to do Next

You can now start exploring the various projects on the Raspberry Pi that you can do without needing a monitor or keyboard.

You may be wondering how you connect to your Raspberry Pi now that you have connected it to your network and have SSH enabled.

There are two possible ways to do this. The first is to try connecting to the raspberrypi hostname. The other way is to retrieve your Pi’s IP address.

To connect to the Raspberry Pi using the hostname, you can use raspberrypi or raspberrypi.local within the IP field of Putty or MobaXTerm.

Using the hostname does not always work, so there are times where you will need to get the IP address of your Raspberry Pi.

There a few different methods that you can use to work out the IP Address of your Raspberry Pi that will go in to in our guide.

Hopefully, at this stage, you will now have successfully set up your Raspberry Pi completely headlessly.

If you have run into any issues with setting up your Pi without a monitor or keyboard, feel free to comment below.

Creating a headless set-up | The Raspberry Pi Guide

Using a standard operating system installation you won’t be able to connect to your Raspberry Pi remotely upon first boot. However, with a couple easy steps this is possible, thus overcoming the need for any keyboard or mouse to be attached.

Table of contents

  1. Overview
  2. Manual set-up
  3. Log in over WiFi

Overview

By default, SSH is not enabled on the Raspberry Pi for security reasons and it will not know the credentials of your Wifi network. Because of this, it will be very hard to connect to it remotely without any peripherals before setting these up.

With newer versions of the Raspberry Pi Operating System, it has become possible to add some manual steps after the installation of the Operating System to enable SSH and set the wifi credentials before first boot.

In March 2021 this has become even easer by the release of a new version of the Raspberry Pi Imager software, which adds a hidden menu that makes it possible to set the hostname, enable SSH, configure the Wifi, and set locale settings directly, all when installing the Operating System. his is by far the best and easy solution now, follow the steps on the installation guide. The manual steps below may still be helpful for some situations so are included for completeness.

Manual set-up

With the default installation your Raspberry Pi, SSH is not enabled by default for security reasons. We can however enable it by placing an empty file named ssh (no extension) in the root of the boot disk.

You can either do this using a text editor program or using the terminal by going to the directory of the drive cd PATHOFDRIVE and then typing touch ssh when on a Mac computer or type NUL >> ssh on windows.

Next your Raspberry Pi will need to know the wireless network from which you will connect. To do so, create a file called wpa_supplicant.conf on the Raspberry Pi SD-card, such as with a text editor program, and add the following information:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
Update_config=1
Country=DE
Network={
    ssid="YourWifiNetwork"
    psk="WifiPassword"
}

Make sure to edit the country code and WiFi credentials such that the WiFi works properly. This file will be automatically picked up on first boot and enable the Raspberry Pi to connect to the network.

Now simply eject the micro SD card safely and boot up your Raspberry Pi.

Using either the Raspberry Pi Imager or following the manual steps above, SSH should be enabled on your new device and it should be connected to your WiFi network. The default user is pi, the hostname raspberrypi, and the password raspberry. You can use these credentials to log in to your Raspberry Pi remotely. Open a terminal window on your other computer and type in:

ssh pi@raspberrypi. local

To be able to access your Raspberry Pi on your network by its hostname (rather than its IP-address) on Windows, you will have to install the Bonjour service (unless you have iTunes installed). You can find the installer here.

Now you should have been able to connect to your newly installed Raspberry Pi without the need of any peripherals! Do not forget to change your hostname and password (follow this guide).


Raspberry Pi configured for Headless mode (no keyboard, mouse or monitor).

General information:

In this article we will set up our Raspberry Pi for the first time without a monitor, keyboard and mouse, in the so-called Headless mode ( eng. Headless — without a head). Let’s connect to it first via SSH for remote work on the command line, then via VNC for remote work in remote desktop mode.

We need:

  • Raspberry Pi of any model
  • microUSB-B 2.5A power supply
  • microSD card from 8GB
  • microSD card reader
  • PC in the same local network with Raspberry

system to a microSD card, but do not rush to remove it from your PC.

We will need to create a few more files on it.

After copying the system to the microSD card, a BOOT disk will appear on your PC, you need to open it and create files in it WPA_SUPPLICANT.CONF and SSH.TXT

  • The first file should be empty and called SSH.TXT — this is necessary for PI to understand that SSH
  • is required at the first load. The second file should be named wpa_supplicant.conf and contain data for connecting to WiFi. When booting, Raspberry itself will transfer the data from this file to /etc/wpa_supplicant/wpa_supplicant.conf
  • Here is an example wpa_supplicant.conf file:

     ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    network={
        ssid="WiFi hotspot name"
        psk="WiFi PASSWORD"
        key_mgmt=WPA-PSK
    }
     

    The name of the access point and the password are written in quotes, for example, if the wifi point is called Druidia and the password is 12345:

     ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    network={
        ssid="Druidia"
        psk="12345"
        key_mgmt=WPA-PSK
    }
     nine0053 

    After creating the files, safely remove the SD card from the PC:

    Next, insert the card into the Raspberry. Connect the camera and turn on the power. After a few seconds, the Pi will boot up and you can start working with it.

    Connecting via SSH:

    Next, you need to connect via SSH.

    New versions of Windows 10 (version>1903) have an ssh client installed by default.

    Press the key combination or right-click on the "Start" button and then "Run". The Run window will open. Enter "cmd" and click "OK":

    A command prompt will open. Enter ssh [email protected] and press , then answer "yes" and press again:

    press :

    If the password was entered correctly, we are greeted by the Raspberry bash console:

    Set up a VNC server:

    We can continue to work with the Pi via ssh and PuTTY, but if a graphical environment is needed, we can configure work through VNC. nine0007

    To do this, type in the command line sudo raspi-config and press enter:

    The Rasberry settings menu will appear:

    Press the "down" key of the keyboard cursor to select item 5 Interfacing Options:

    Press enter, the menu for enabling / disabling interfaces will open , select P3 VNC, press enter again:

    The menu will ask you to enable / disable the VNC server, answer :

    Then press :

    We are back in the main menu. Next, you need to adjust the screen resolution, otherwise the VNC viewer will not be able to display the desktop. Select the Advanced Options menu item, press enter:

    Next, select A5 Resolution, press enter:

    Next, select the appropriate screen resolution, press enter:

    Press the keyboard arrow to the right, press :

    We are again in the main menu, press the right arrow on the keyboard twice , click :

    Answer the question about rebooting :

    Close the PuTTY window.

    Install VNC viewer

    Download and install VNC viewer from RealVNC. This link will open the installer selection page for different operating systems. We select the necessary one (in our case, Windows). Download the installer and run it. After installation, open the VNC viewer:

    Select File -> New connection...

    A window for creating connections will open: Clicking the mouse will open the username and password entry window. When you first start the Raspian system, the default login is pi, the password is raspberry. We enter them:

    Press ok - we are welcomed by the Raspbian graphical environment:

    Raspberry Pi Headless Mount - PiCockpit

    To run your Raspberry Pi in headless mode, all you need is a microSD card and a power adapter. Learn how to connect to Pi from Windows.

    Requirements

    Hardware

    • Raspberry Pi
    • MicroSD Card (16 GB or more)
    • MicroSD Card Adapter / SD Card Reader
    • Power Adapter
    • Windows PC
    • Software
    • 0114
      • Raspberry Pi Imager
      • PuTTY
      • VNC Viewer

      Make sure you have all the hardware requirements at hand and download the free software we will need for this setup.

      Steps

      • 1 Set up OS
      • 2 Login to Headless via SSH
      • 3 Enable VNC server
      • 4 Connect Headless via VNC Viewer I use a microSD to SD adapter because my PC has an SD card slot. nine0007

        Launch the Raspberry Pi Imager and select the MicroSD card. Choose Raspberry Pi OS (32-bit) if you need a desktop environment. If not, the best option would be Raspberry Pi OS Lite (32-bit) .

        Raspberry Pi Imager

        Click on the settings icon in the lower right corner or Ctrl+Shift+x to open more options.

        In the Advanced Options section, check the box Enable SSH and Use password authentication . You can optionally set a default username and password. Enable Configure Wifi , enter the SSID and password, and select the Wifi country.

        Additional parameters for Headless mode

        Save settings and press button Write button. It will take a couple of minutes until the OS is flashed to the microSD card.

        After that, insert the MicroSD card into the Raspberry Pi and turn it on. Again, you need to wait about one minute before proceeding with the next step because the Pi needs a little time to boot up and connect to Wifi. nine0007

        Congratulations! Your Pi is now set up for headless use.

        Now you need to find out the IP address of your Pi. The easiest way to check IP from Windows is to use the command line. Press Ctrl+r and type cmd to launch a command prompt.

        Launching a command line

        The default Raspberry Pi host name is raspberrypi.local unless you have configured it differently in the Raspberry Pi Imager advanced options above. So, to find out the IP address, follow these steps

         nslookup raspberrypi 

        You should see something like this.

        nslookup result

        First IP under Addresses: is the IP we are looking for, in my case 192.168.1.140

        If you get an error, your Pi may not have booted up yet or is not connected to Wifi. Check your Raspberry Pi Imager settings again to make sure there are no typos.

        Now that we've figured out the IP address, the next step to complete the Headless installation is to use PuTTY to start an SSH session. ssh means S ecure SH ell and is a way to log into devices remotely.

        Start PuTTY and enter an IP address in the Hostname (or IP address) field field. Make sure SSH is selected as the connection type and click the Open button.

        PuTTY settings to use Headless

        Log in to the Pi. The default username is pi and the default password is raspberry . Be sure to change your password the first time you use it. nine0007

        If all you need is access to the Raspberry Pi console, that's it. However, if you want to access the desktop environment, read on.

        3 Enable VNC Server

        Since we are going to use the VNC Viewer to display the desktop, we need to enable the VNC Server on our Raspberry Pi. Luckily, it's pretty easy.

        In a PuTTY SSH session, do the following:

         sudo raspi-config 

        Select 3 Interface options then I3 VNC and finally Yes and OK .