Connect to Raspberry from a PC or Mac via Ethernet RJ45 cable


Updated February 23, 2021 • 0 • 0

Have you ever needed to use your Raspberry Pi via SSH when you didn't have a Wifi network? Maybe you have, and fortunately, there is a solution! In this tutorial, we'll see how to connect to your Raspberry Pi from a PC via SSH, without Wifi network. To do this, we'll use a simple Ethernet cable between the Raspberry Pi and our computer.

Connect to Raspberry Pi via Ethernet from your computer - Raspberry Lab

Prerequisites

To complete this tutorial, you'll need:

... and that's it!

MicroSD Card Modifications

To establish a connection between the Raspberry Pi and a computer, you must first assign a fixed IP address to the Raspberry Pi. To do this, start by retrieving the MicroSD card and inserting it into the computer to read its contents.
ℹ️ The microSD card should appear with the volume name boot on the computer.
Then look for the file "cmdline.txt": that's the one we'll modify. It's recommended to backup this file before editing it.

Volume boot - explorateur Windows

Now you can open the file and add at the end of the line (no line break) the following text:

ip=169.254.x.x   (x to choose between 169.254.0.0 and 169.254.255.255)    Example: 169.254.25.25

Fill in the 'x' with numbers of your choice to get your IP. Then remember to write down this address somewhere 😉.
Once done, save the file (ctrl S), retrieve the microSD card, then reinsert it into the Raspberry Pi.

Connection and Testing

Now that the card is properly configured, you can connect the Raspberry Pi to the computer using the Ethernet ports on each. Power up the Raspberry Pi and wait ~1 minute for it to initialize. Once the Raspberry Pi is ready, you can verify everything works by opening the Windows command prompt or Terminal on Mac and typing:

ping 169.254.25.25 (in the case of the IP address suggested earlier)

If there's no error, everything is fine, everything is ready to start the SSH connection.
Note that it's still possible to access the Internet on the computer via Wifi.

Putty Configuration

Now that the connection is tested, we can proceed with configuring Putty or equivalent. So open your SSH software, go to Connection-/-SSH-/-X11 and check Enable X11 forwarding.

Activation X11 - Putty

Once checked, return to Session, and enter the Raspberry Pi IP address [previously noted] in the Host Name field.

All that's left is to enter your credentials (Default: login = pi and password = raspberry) and you're finally connected to the Raspberry Pi console, while being in an environment without internet connection!


Read next

Article image

Connect to Raspberry Pi desktop remotely


Article image

Essential accessories to get started with Raspberry Pi 4