One of the first steps in setting up your Raspberry Pi is connecting it to a screen. This allows you to view the Raspberry Pi OS desktop environment and to enable remote connection. Remote connection with Secure SHell (SSH) is a convenient way to access your Raspberry Pi without connecting it to a monitor. This is easiest to do if you’ve already set up your display, although it is possible to enable SSH without it. Sections 2 and 3 will outline connecting via SSH both with and without a display.
This article assumes that you have already installed Raspberry Pi OS onto your Pi. The easiest way to do this is with the graphical SD card writing tool developed by Raspberry Pi called Raspberry Pi Imager. You will also need to connect your Raspberry Pi to WiFi. While two options for this (ethernet and wireless) are briefly discussed in this tutorial, it is not the main focus.
NOTE: All of these sections involve making changes to Raspberry Pi Settings. Make sure you save your changes before you remove your SD card!
Section 1: Connecting to a display
Section 2: Connecting With SSH Using a Monitor
Section 3: Connecting With SSH Without a Monitor
Section 1: Connecting to a Display
What you’ll need:
- HDMI connection cables*
- A display
- A keyboard and mouse
*For newer Raspberry Pis, you’ll need to connect a micro HDMI to the receiving port of your display. This can be an HDMI, DVI, or VGA port. You might need to use an adapter. If you have an older Raspberry Pi, you’ll need to use HDMI instead of micro HDMI for the output.
NOTE: Depending on the OS that you’re using, you might be able to skip steps 1 and 2, and just power on the Raspberry Pi with the SD card and HDMI setup to immediately connect to the display.
- First, you’ll need to insert the Raspberry Pi’s SD card into the computer so that you can make some changes to the config.text file used at the time of booting.
- Open the config.text file and remove the # symbols on the two lines of code containing “#hdmi_force_hotplug=1” and “#hdmi_drive=2.” This enables the code, which allows output and sets the screen resolution. Save the changes before removing the SD card.
- You can also change the screen resolution by editing the lines “#hdmi_group=1” and “#hdmi_mode=4.” Replace them with 2 and 16, respectively.
- Prior to connecting to a display, you’ll need to insert the SD card and turn on the power supply of your Raspberry Pi.
- Then, you’ll connect whichever HDMI cables you chose above. You should see the interface on your monitor!
Section 2: Connecting With SSH Using a Monitor
- Connect your Raspberry Pi to the same WiFi network as your remote computer. You can do this by connecting an ethernet cable to your router, or wirelessly:
- Use Raspberry Pi Imager to set up the WiFi. Navigate to Advanced Options from the Imager’s home screen via CMD + Shift + x (or Ctrl + Shift for Windows). Check the “Configure WiFi” box and enter the credentials.
- Open a command line. This is the terminal in Mac, and can be found under Utilities or by Spotlight searching with command+spacebar and searching “terminal.” In Windows, this is called Command Prompt, and can be found under Start → Command Prompt.
- Enable SSH on your Raspberry Pi. Click on the Raspberry Pi Menu on your monitor and navigate to Preferences → Raspberry Pi Configuration → Interfaces → Switch to Enable SSH. Save and restart your Raspberry Pi. You can also use the Advanced Options section (discussed in Step 1) to check the Enable SSH box and enter the corresponding authentication information. This process is the main difference between connecting with a monitor and connecting without, as it can also be done using the command line, which will be discussed in Section 3.
- In the command line, connect using the ssh command. If you’re using Raspbian, you’ll type in “ssh pi@raspberrypi” because raspberrypi is the default hostname. You can also replace “raspberrypi” with the IP address or whatever hostname you are using.
- Enter your password when prompted. The default is “username: pi and password: raspberry.” If you receive any host warnings about authenticity, just click yes to continue connecting. It will not happen after connecting for the first time.
Section 3: Connecting With SSH Without a Monitor
The main difference with this method is that you will not be able to enable SSH using the interface. You will also have to insert the Pi SD card directly into your computer if you don’t have the capabilities to connect the Pi to the monitor.
- Insert the Pi SD card into your computer.
- Enable SSH. If the ssh file already exists, then it means ssh is already enabled upon booting the Pi. Otherwise, complete the following steps:
- Open a command line. This is the terminal in Mac, and can be found under Utilities or by Spotlight searching with command+spacebar and searching “terminal.” In Windows, this is called Command Prompt, and can be found under Start → Command Prompt.
- Find the boot directory. Use bash command “cd” to navigate into /Volumes/boot.
- Create an ssh file using “touch ssh”
- Switch the SD card back into the Pi.
- Once you boot your Pi, you will be able to connect via SSH as long as the Pi is connected to WiFi! (See step 1 in section 2 if you need assistance with WiFi connection.)
If you have questions about any of these processes, feel free to comment on this post!
1 Comment. Leave new
[…] A Raspberry Pi with an operating system that is attached to a regular computer setup, or connected via SSH […]