Skip to content

2. Connecting to your RPi

SamVanderstraeten edited this page Jan 31, 2023 · 10 revisions

Connecting to the Raspberry Pi

You'll use SSH to connect to your Raspberry Pi from your computer. This enables you to access the command line of a Raspberry Pi from another computer or device on the same network.

By default, SSH is disabled on a new RPi installation, but if you've completed all previous steps, you should have enabled it in the Preferences screen. If not, go check Enable SSH on the first page.

First off, you'll have to make sure that the Raspberry Pi and the computer you are using are connected to the same network. This can be a wifi network or a mobile hotspot on your smartphone.

Connecting to a network is probably easiest in desktop mode, when a monitor is attached to the RPi. However, when preparing a network connection to e.g. a personal hotspot, it might prove useful to configure all network settings in advance in 'SSH-mode'. Changes to network configuration (WiFi passwords etc.) can be done manually with

nano /etc/wpa_supplicant/wpa_supplicant.conf

More info about the wpa_supplicant file

SSH

Once your laptop and the RPi are on the same network, connecting to the RPi with SSH is easy:

ssh <username>@<raspberrypi-IP>

So, this could look like this:

The username should be known. This could be pi, rttf or some other name you chose while configuring the RPi.

Now you'll need to determine which IP your Raspberry Pi is using. There are several options available to do this.

From desktop

If you have a screen connected to your RPi:

  1. Turn on your Raspberry Pi, and make sure it's connected to a network.
  2. Open a terminal on your Pi.
  3. Enter the command hostname -I in the terminal.
  4. Your Pi's IP address is the first part of the output: it will contain four numbers separated by periods, e.g. like so: 192. xx. x.x. This is the IP you're looking for.

Using ping

You can try pinging the RPi. ping sends a small package to a given device in the network, to which it will respond if it's available.

ping raspberrypi

If it responds, you'll see the RPi's IP in the output. There is no guarantee that the RPi will respond, though, so you might have to resort to the next step.

Using nmap

You can use a network mapping tool to find the IP of your RPi. This will be a bit more tricky.

  1. Install nmap on your computer, using sudo apt install nmap
  2. Find your local IP address: hostname -I
  3. Let's say your IP address is 192.168.1.45. We know that the subnet range is 192.168.1.0/24. Just swap out the last number with 0/24 to get your subnet range. Using 0/24 is the equivalent to saying it ranges from 1 to 255.
  4. Now, we'll scan the subnet range for devices that respond to a ping call, using the nmap tool:
sudo nmap -sn 192.168.1.0/24
  1. In the resulting list, you'll be able to see the devices in the network range that respond to a ping call. Trace down your RPi in this list and you'll see the IP address that was assigned to it.
MAC Address: B8:27:EB:EA:E0:D4 (Raspberry Pi Foundation)
Nmap scan report for 192.168.0.174

More info and a complete guide, including other operating systems

Next steps

If you successfully connected to your RPi, let's get going and install all the necessary software on the RPi. Check out this page for a detailed description.