How To Connect Raspberry Pi To Laptop

James J. Davis
2 min readDec 10, 2020

--

I was wondering if there was a way to connect Raspberry Pi using an Ethernet cable directly to a laptop? I was trying to use this video lesson for beginners and in the end created my own list which I want to share with you today.

So, you will need

1. A regular Ethernet cable
2. Laptop
3. Raspberry Pi 2+

Prerequisites

Installing network-manager and nmap

sudo apt-get install network-manager
sudo apt-get install nmap

Editing a wired connection

  1. Change the IpV4 settings to “Share to other computers”
  2. Save
  3. Reboot

Share WiFi from your laptop via Ethernet cable

Connect your RPi to your laptop using an Ethernet cable and check the broadcast address of the connection:

/sbin/ifconfig eth1 | grep “Bcast” | awk -F: ‘{print $3}’ | awk ‘{print $1}’

For example, 10.41.0.255. Use this address to find out the IP address of your RPi

nmap -n -sP 10.41.0.255/24

Log in to your RPi from your laptop (-Y with X redirection).

ssh -Y pi@10.42.0.96

Great! Now your RPi is connected to your laptop and the RPi can share a WiFi connection.

pi@raspberrypi ~ $

Share the screen and keyboard

Install vncserver on your Raspberry Pi

sudo apt-get update
sudo apt-get install tightvncserver

Install vncviewer on your laptop by downloading RealVNC (it supports multiple platforms).
To be able to copy & paste from VNC server to VNC viewer, you need to install autocutsel on your RPi.

sudo apt-get install autocutsel

If that site doesn’t work, try downloading the .deb directly from a mirror site like mirror and install it, for example

sudo dpkg -i autocutsel_0.10.0–1_armhf.deb

Run vncserver on your RPi

vncserver :1

Add autocutsel to /home/pi/.vnc/xstartup

#!/bin/sh
xrdb $HOME/.Xresources xsetroot -solid grey
autocutsel -fork
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession

Run vncviewer on your laptop

vncviewer

The vncviewer window will appear and you will enter the IP address of your RPi (given by your laptop) and then port 1, which is your VNC server. For example: 10.42.0.96:1 in my case.

Connect it to the vncserver hosted on your RPi by entering a password (set the password yourself)

Now you can see the RPi desktop on your laptop!

Read more about RPi zero projects:

--

--

James J. Davis
James J. Davis

Written by James J. Davis

Software developer with 30 years of experience

No responses yet