Control your Raspberry Pi from Anywhere in the World with a Few Easy Steps

Learn how to access and control your Raspberry Pi remotely using Secure Shell (SSH) and the popular VNC Viewer software. This guide will help you set up remote access, connect to your Raspberry Pi fro …


Updated August 24, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


Learn how to access and control your Raspberry Pi remotely using Secure Shell (SSH) and the popular VNC Viewer software. This guide will help you set up remote access, connect to your Raspberry Pi from anywhere, and troubleshoot common issues.

If you want to operate your Raspberry Pi without being physically present at its location, you can use Secure Shell (SSH) to remotely access it from another computer or device over a network. Additionally, you can use VNC Viewer to see and interact with the graphical user interface of your Raspberry Pi’s desktop remotely. This guide will show you how to set up remote access using SSH and VNC Viewer on both Windows and macOS/Linux systems.

Setting Up Remote Access via SSH

  1. Enable SSH on your Raspberry Pi:
    • Open the terminal on your Raspberry Pi and enter the following command to enable SSH: sudo systemctl enable ssh
    • Start the SSH service with this command: sudo systemctl start ssh
  2. Find the IP address of your Raspberry Pi:
    • On your Raspberry Pi, run the following command in the terminal to display its network information: ifconfig
    • Note down the IPv4 address under wlan0 or eth0 (depending on whether you’re connected via Wi-Fi or Ethernet).
  3. Connect to your Raspberry Pi from another computer or device using an SSH client:
    • On Windows, download and install PuTTY from https://www.putty.org/.
    • On macOS or Linux, open a terminal and type the following command (replace <IP address> with your Raspberry Pi’s IPv4 address): ssh pi@<IP address>
    • Enter raspberry as the password when prompted.
  4. To connect securely from another device, generate an SSH key pair on your local computer and copy the public key to your Raspberry Pi:
    • On your local computer, run the following command in the terminal (press Enter when asked for a passphrase to leave it blank): ssh-keygen -t rsa
    • Copy the contents of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys on your Raspberry Pi: cat ~/.ssh/id_rsa.pub | ssh pi@<IP address> "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys"
  5. Disable password authentication in sshd_config to enhance security:
    • On your Raspberry Pi, edit the SSH configuration file with this command: sudo nano /etc/ssh/sshd_config
    • Locate the line #PasswordAuthentication yes and change it to PasswordAuthentication no. Save and exit the file.
    • Restart the SSH service for changes to take effect: sudo systemctl restart ssh
  6. Update your Raspberry Pi’s firewall settings to allow incoming SSH connections:
    • Run this command on your Raspberry Pi to open port 22 (SSH) in ufw: sudo ufw allow 22/tcp

Now you can remotely access your Raspberry Pi using the IP address, username (pi), and SSH key or password.

Setting Up Remote Desktop Access with VNC Viewer

  1. Install TightVNC server on your Raspberry Pi:
    • Run this command in the terminal to update your package list and install TightVNC: sudo apt-get update && sudo apt-get install tightvncserver
  2. Configure the VNC server:
    • Run vncserver in the terminal, set a password when prompted, and configure any other settings you need.
  3. Install a VNC viewer on your local computer (e.g., TightVNC Viewer for Windows or macOS/Linux):
  4. Connect to your Raspberry Pi using the VNC viewer:
    • Enter the IP address and port number (<IP address>:1) in the VNC viewer, and log in with the password you set earlier.

You can now remotely access and control your Raspberry Pi’s desktop from any device on the network or internet.

Troubleshooting Remote Access

If you encounter issues connecting to your Raspberry Pi remotely, try the following troubleshooting steps:

  • Check if SSH is running: Run sudo systemctl status ssh on your Raspberry Pi. If it’s not active, restart the service with sudo systemctl start ssh.
  • Make sure port 22 is open on your router and firewall settings allow incoming connections to the Raspberry Pi.
  • Verify that you’re using the correct IP address and credentials (username and password/key).
  • Check if TightVNC server is running: Run vncserver -list on your Raspberry Pi to see a list of active sessions, or ps aux | grep Xvnc for processes. If it’s not running, start it with vncserver.
  • Ensure you have the correct VNC viewer settings (IP address, port number, and password).

With these steps, you can access your Raspberry Pi remotely from anywhere in the world using SSH and VNC Viewer. Enjoy the convenience of managing your Raspberry Pi from afar!