Guide: Connect Raspberry Pi to Linux PC w. Ethernet Cable

How to connect headless to a Raspberry Pi unit from a Linux PC using only a cable, including how to find the remote IP in several ways.

This is how to connect to your Pi with only an Ethernet cable while not knowing the IP address of the Pi. To provide an use-case for this guide the aim will be to connect to the Pi from the Linux PC using SSH.

(Edition 4)

  1. Requirements
  2. Prepare the Raspberry Pi
  3. Prepare the Linux PC
  4. Connect the units
  5. Try setting up Network-Manager
  6. Find the IP-address of the Pi
  7. IP found: Next steps
  8. More


You will need:

The guide has an extra number of ways to solve the task at hand and to avoid some common pitfalls (eg "can't find the IP")

Prepare the Raspberry Pi

Enable SSH on the Pi

If you want to connect to the Pi using SSH you will need to enable SSH on the Pi first:

With access to Raspberry Pi using keyboard, screen, etc

Use the "Raspberry Config" tool, or run # sudo raspi-config from terminal. You will likely figure out the rest.

Without access (so-called "headless")

Remove the SD card from the Pi and plug it into the SD card reader on your Linux PC. Navigate to the folder/partition "/boot/" and create a file with the name "ssh" (# touch ssh will do). Then put the card back.

If your PC does not have a SD card reader, you will have to get one with an USB plug.

Prepare the Linux PC

Check if your PC is SSH enabled

If you want to use SSH, you should probably make sure your Linux PC has SSH installed. If you have SSH below command will return a path:

# which ssh

No ssh? - install it: # sudo apt install ssh. Retry.

Find the IP-address of the Linux PC

# hostname -I

Connect the units

Plug in the Ethernet cable

Plug in the cable on both devices. If your PC does not have an "Ethernet port" (a RJ-45 outlet) you will have to get an USB-to-RJ-45 converter plug.

Also, power up the Pi.

Check connection

If/when you can run this in a terminal and get a sensible reply you already have a connection:

# ping raspberrypi.local

Try setting up Network-Manager

This may, or may not, be all you need to do.

  1. On the Linux PC, right-click network-manager (in the GUI, probably on the Desktop panel)
  2. Choose "Edit Connections"
  3. In the pop-up, click "+" (plus-sign)
  4. Choose the type "Ethernet" -> click "Create"
  5. In the input field "Name" (top) type eg. "Raspberry Pi Over Ethernet"
  6. On tab "General", check the mark "Connect automatically..." and choose some sane value, eg. "0" (zero)
  7. On tab "Ethernet", in "Device" field, input the device name, eg "eth0" (see below)
  8. On tab "IPv4 Settings", in "Method" drop-down, select "Link-Local" Only
  9. Click "Save" and wait for connection

Ping as above, and if you get a sane response you're set. Just 'head for "SSH" instructions below if you want to (it's easy).

If you're still not connected, no problem

Find the IP-address of the Raspberry Pi

So, no luck I guess. No big deal. The Raspberry IP-address will start with 169.254., so we're half way already.

# sudo ifconfig

Identify your Ethernet connection and look for an IP starting with "169.254". Your Ethernet connection may be called eg. "eth0", or even something as exotic as "enp1s0". It's all good.

Note this name! Below we will use "ETHNAME" as placeholder.

So, no ifconfig? - Well, it's deprecated. But you may still install it: # sudo apt install net-tools.

Alternatively use "ip" (the replacement for ifconfig), eg. one of these:

# ip address
# ip a
# ip r
- you know what to look for.

More ways to find the remote IP

So, no IP? No problem:

# sudo arp raspberrypi.local

Still no luck? Try:

# sudo arp -a | grep -E --ignore-case 'b8:27:eb|dc:a6:32'

This looks for the MAC-address of the Pi. Those starting with "b8" are for Pi version =< 3 and those starting with "dc" are for version 4.

So, no arp? - install it: # sudo apt install arping. Retry.

Still no luck? Try:

# sudo arp-scan --interface=ETHNAME

- and be patient. After a while you may see the likeness of:    b1:23:cd:45:6e:7f    Raspberry Pi Foundation

First block is the IP of the PI, second block is its MAC address.

So, no arp-scan? - install it: # sudo apt install arp-scan. Retry.

Still no luck? Try:

# sudo tcpdump | grep 169.254

- and be patient. After a while you may see the likeness of:

11:50:45.400179 ARP, Request who-has tell, length 46

IP after "tell" belongs to Raspberry

So, no tcpdump? - install it: # sudo apt install tcpdump. Retry.

IP found: Next steps

Below we will use "PI-IP" as a placeholder for the Raspberry Pi IP address. Ping it to see how it responds

# ping PI-IP

The placeholder "PI-IP"" should be replaced with the IP you found above.

The SSH part: Communicating through the cable

This is the easy part ("PI-IP" below is still just a placeholder):

# ssh pi@PI-IP (terminal only)

# ssh -Y pi@PI-IP (gui programs enabled)

You may even be able to do:

# ssh pi@raspberrypi.local

To close the SSH connection, enter "exit" in the connected terminal:

# exit


There are official pages on this:

Also, there are many more ways to do it, eg. by using nmap to find IPs, using router hardware, manipulating the "config.txt", "cmdline.txt", and/or your "interfaces" file, or setting up a DHCP-server on your Linux box. Let's not go there.



Document URL: