HomeHow ToHow to set up a Raspberry Pi without connecting to a monitor

How to set up a Raspberry Pi without connecting it to a monitor

Pi Raspberry Pis are very convenient because they are cheap and small, but connecting them to a monitor, keyboard, and mouse takes up a lot more space and money. If you are just trying to use your Pi for programming or to control devices like lights, motors, and sensors, you don't need to connect it to a monitor because you can control the system remotely using a VNC or SSH client on your main computer. We call this a "headless" Raspberry Pi setup.

By default, the official operating system of the Raspberry Pi, Raspbian, is installed with all remote access methods disabled. But the good news is that you don’t need to connect to a screen to enable them. By following the instructions below, you can create a headless Raspberry Pi for remote access.

Installing Raspbian on the microSD card

  1. Insert a microSD card into your computer. Your card must be 8GB or larger (the lite version of Raspbian will use less space).
  2. Download Raspbian in .zip format. Prefer the full version rather than the lite version.
  3. Install and launch Etcher.
  4. Click the Select image button and choose the .zip file you just downloaded.
  5. Click the Flash button.

Etcher will take a few minutes to install Raspbian onto your microSD card. When it finishes – at least on Windows – you will see a series of notifications asking you to configure the card. Close these windows or click «cancel» (otherwise, it will be configured via the operating system).

  1. Write an empty text file named “ssh” (without a file extension) in the card’s directory. When it sees the “ssh” on the first boot, Raspbian will automatically enable SSH (Secure Socket Shell), which will allow you to gain remote access to the Pi command line from your computer.
  2. Configure a network connection for the Raspberry Pi.

Even though you have enabled SSH, which will allow you to connect and issue terminal commands, you still need a way to reach your Pi. You can connect via Wi-Fi/Ethernet, via a direct Ethernet connection, or via a direct USB connection. The instructions for each are below.

Headless Wi-Fi / Ethernet

To set up a Wi‑Fi connection on a headless Raspberry Pi, create a text file named wpa_supplicant.conf and place it in the microSD card directory. You will need to put the following text in the file:

country=US
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid=”your_wifi_ssid”
scan_ssid=1
psk=”your_wifi_password”
key_mgmt=WPA-PSK
}

Change the country to “GB” for the United Kingdom or to another country code for a different country, and enter your actual SSID and password. After booting, Raspbian will connect you to this network. However, if you are on a public Wi‑Fi network that requires you to click the “Ok” option on a splash page before you can access the Internet, this method will not work.

Do you prefer Ethernet? If you connect the Raspberry Pi directly to a wired network, you will be able to access it by its name (raspberrypi or raspberrypi.local) without changing any other files.

Direct USB connection (Pi Zero only / Zero W)

With the direct USB connection, you connect the Pi Zero W directly to a port on your computer. This method is fantastic because it works regardless of where you are (even if there is no Wi-Fi available) and only requires a cable. However, you can only do it on Pi Zero or Zero W.

  1. Open the config.txt file in the micro SD card directory, add the line dtoverlay = dwc2 at the bottom of the file and save.
  2. Open cmdline.txt and add the text sections load = dwc2, g_ether after the word rootwait and save the file.
  3. Download and install Bonjour Print Services from apple.com (if you have Windows). It seems strange that you need an Apple program to access a Pi from Windows, but this helps your computer see the Pi. Ignore the name.
  4. Connect the micro USB cable to the port labeled “USB” on the Pi Zero. It will not work if you connect it to the port labeled “PWR”. Additionally, the “USB” port will power your Pi, so you do not need to connect a special power cable.

Direct Ethernet connection

If your computer has a backup Ethernet port or you have an Ethernet-to-USB dongle, you can use a network cable to go directly from your Pi to your computer. Just make sure you have installed Bonjour on your computer and that SSH is enabled on the Pi. Then you can connect the two devices via Ethernet.

If you want the Raspberry Pi to obtain its Internet connection from your computer via the Ethernet port, you need to do the following (on Windows 10):

  1. Go to the “Network Connections” menu, which is part of the (old) Control Panel. You can reach this screen by going to Settings->Network & Internet->Wi-Fi and, then clicking the “Change Adapter Settings” option on the right side of the screen.
  2.  Right-click the adapter that is connected to the Internet and select properties.
  3. Enable the “Allow other network users to connect” option in the “Sharing” tab.
  4. Select the Ethernet port that is connected to the Raspberry Pi from the “Home networking connection” menu and click OK.

Connection via SSH

After you connect the Pi to your network or directly to your computer, you will need to create an SSH connection.

  1. Download and install Putty. Putty is the leading SSH client for Windows.
  2. Enter raspberrypi or raspberrypi.local as the address you want to connect to in Putty and click Open. Usually you need to add .local if the Pi is directly connected to your computer via USB or Ethernet cable.
  3. Click OK if you receive a security warning notification. It's not a problem.
  4. Enter «pi» as username and «raspberry» as password. You may want to change them later.

Now you are logged into the command line, but if you want to access the GUI you will need to enable VNC.

Enable and connect via VNC

  1. Type sudo raspi-config at the command line. It opens a configuration application.
  2. Select Interfacing Options (number 5 in the list)
  3. Select VNC (number 3 in the menu)
  4. Select Yes.
  5. Press Enter to confirm that the VNC server is enabled.
  6. Select Finish.

On your PC:

  1. Download, install and launch VNC Viewer.
  2. Select New connection from the File menu.
  3. Enter raspberry.local in the “VNC Server” field. If this does not work, try again with the name “raspberrypi” without .local.
  4. Click OK.
  5. Double-click the connection icon to connect.
  6. Click OK if a security warning appears.
  7. Enter the username and password of the Pi when prompted. The defaults are: username: pi and password: raspberry. Click the OK button.

The Raspberry Pi desktop will then appear in a window on your host computer's desktop. You will be able to control everything from there.

📧
Subscribe to the SecNews Newsletter

The most important Security & Technology news in your Inbox.

Absentee Mia
Absentee Miahttps://www.secnews.gr
Being your self, in a world that constantly tries to change you, is your greatest achievement

SEARCH

FOLLOW US

📧
Newsletter SecNews
The most important Security & Technology news in your inbox.

LIVE NEWS