10/13/24

Intro

Sometimes you need to access a Raspberry Pi without connecting it to a monitor, keyboard, and mouse. Perhaps the Raspberry Pi is embedded in a robot or mounted in an inconvenient location. Or maybe you don’t have a spare monitor. To remotely control your Raspberry Pi from another device on your local network, use one of the following services:

  • SSH (Secure SHell)- provides secure access to a terminal session on your Raspberry Pi via SSH.
  • VNC (Virtual Network Computing)- provides secure access to a desktop screen share on your Raspberry Pi.
    • All you need is another computer, a local network, and the local IP address of your Raspberry Pi.
  • Raspberry Pi Connect- shares your Raspberry Pi’s screen securely with no need to determine your local IP address.

Get Raspberry Pi’s IP address

  • Show the Raspberry Pi’s IP:
    hostname -I

Optional: Set up static IP


9/5/25

SSH into Raspberry Pi

Hint

If you have an OS other than Raspbian (e.g. Ubuntu), you need to first install the raspi-config utility and SSH Server

Install SSH Server and raspi-config (Ubuntu)

  • Install the raspi-config utility
sudo apt install raspi-config
  • Install SSH Server
sudo apt install openssh-server -y

Enable SSH Server 1

  • Open the raspi-config utility
sudo raspi-config
  • Select Interface Options → SSH, then choose Enable

Connect to an SSH Server

  • Open a terminal from another computer (Linux, macOS, WSL, or an SSH client (e.g., PuTTY for Windows))

  • Use the SSH command to connect to your Raspberry Pi. Replace <user> with your username and <ip-address> with the Raspberry Pi’s IP address:

    ssh <user>@<ip-address>

    Example:

    ssh pi@192.168.68.121
  • Enter the password for the Raspberry Pi when prompted (See section below to bypass the password)

  • Once authenticated, you will be logged into the Raspberry Pi’s terminal remotely

<username>@<hostname> ~ $

Optional: Set Up Passwordless SSH (via SSH keys)

Note: Create the key on your local machine (i.e. WSL for Windows)

  • Check if already have an SSH key on local machine
ls ~/.ssh/id_rsa
  • Generate SSH keys on your local machine (e.g. laptop)
ssh-keygen -t rsa -b 4096
  • Just press Enter through the prompts to accept the defaults:
Enter file in which to save the key (/home/youruser/.ssh/id_rsa): [Enter]
Enter passphrase (empty for no passphrase): [Optional]
  • This creates:

    • ~/.ssh/id_rsa → Private key (keep this secret)
    • ~/.ssh/id_rsa.pub → Public key (safe to share)
  • Copy the public key to the Raspberry Pi (You’ll be prompted for the Pi’s password one last time)

    ssh-copy-id <user>@<ip-address>
  • You can now SSH into your Raspberry Pi without a password:

    ssh <user>@<ip-address>

Transfer Files to/from Your Pi

Use scp to securely copy files between your local machine and the Pi:

  • Copy a file to the Pi:
    scp file.txt pi@<RPI_IP_ADDRESS>:/home/pi/
  • Copy a file from the Pi:
scp pi@

Use SSH to log texts to the pi

  • Use SSH with echo
ssh pi@<RPI_IP_ADDRESS> "echo 'Hello from my PC!' >> ~/messages.log"

Screen share with VNC

https://www.raspberrypi.com/documentation/computers/remote-access.html#vnc

Footnotes

  1. https://www.raspberrypi.com/documentation/computers/remote-access.html#ssh ↩