Access your Raspberry Pi from anywhere with just a few clicks!

Learn how to remotely connect to your Raspberry Pi from your Mac computer using SSH (Secure Shell) and the Remote Desktop Protocol. This guide will help you set up remote access in no time, so you can …


Updated August 15, 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 remotely connect to your Raspberry Pi from your Mac computer using SSH (Secure Shell) and the Remote Desktop Protocol. This guide will help you set up remote access in no time, so you can manage your Raspberry Pi projects without ever having to touch it physically.

Overview

Remote access is a powerful tool for managing and controlling your Raspberry Pi from anywhere in the world. Whether you’re on vacation or working from home, being able to connect to your Raspberry Pi over the internet can save time and hassle. In this article, we will show you how to set up remote access using two popular protocols: SSH (Secure Shell) and Remote Desktop Protocol (RDP).

Setting Up SSH

SSH is a secure method for connecting to your Raspberry Pi from another device over the internet. It allows you to run commands, transfer files, and manage your Raspberry Pi as if you were sitting right in front of it. Here’s how to set up SSH on both your Mac and your Raspberry Pi:

On Your Mac

  1. Open Terminal on your Mac computer. You can find it by searching for “Terminal” using Spotlight or by going to Applications > Utilities > Terminal.
  2. Type the following command into the terminal and press Enter: ssh-keygen -t rsa -b 4096. This will generate a new SSH key pair on your Mac. Press Enter again when prompted to accept the default file location.
  3. Once the keys are generated, run pbcopy < ~/.ssh/id_rsa.pub to copy your public key to your clipboard. This key will be used to authenticate you with your Raspberry Pi later on.

On Your Raspberry Pi

  1. Open a terminal window on your Raspberry Pi and create a new file called authorized_keys in the .ssh directory: touch ~/.ssh/authorized_keys.
  2. Open the file with nano (or your favorite text editor) using this command: nano ~/.ssh/authorized_keys.
  3. Paste your copied public key from your Mac into the file and save it by pressing Ctrl+X, then Y, and Enter.
  4. Set the correct permissions for the .ssh directory and files by running chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys.
  5. Enable SSH on your Raspberry Pi by editing /boot/config.txt. Add enable_uart=1 to the bottom of the file and save it using sudo nano /boot/config.txt. You may need to enable the UART interface in Preferences > Raspberry Pi Configuration if it’s not already enabled.
  6. Reboot your Raspberry Pi with sudo reboot.

Connecting via SSH

Now that you have set up SSH on both your Mac and your Raspberry Pi, you can connect to your Raspberry Pi from anywhere.

  1. Find the IP address of your Raspberry Pi by running ifconfig in a terminal window on the device itself. Look for the “inet” value under “wlan0” or “eth0”.
  2. On your Mac, open Terminal and type ssh pi@<IP ADDRESS> (replace <IP ADDRESS> with the IP address of your Raspberry Pi). Press Enter to connect.
  3. When prompted, enter the password for the “pi” user account on your Raspberry Pi. You should now be connected!

Setting Up Remote Desktop Protocol (RDP)

Remote Desktop Protocol (RDP) allows you to access your Raspberry Pi’s graphical interface remotely, as if you were sitting in front of it. Here’s how to set up RDP on both your Mac and your Raspberry Pi:

On Your Raspberry Pi

  1. Install the necessary packages for RDP by running sudo apt-get update && sudo apt-get install xrdp.
  2. Reboot your Raspberry Pi with sudo reboot to apply the changes.
  3. After the reboot, connect to your Raspberry Pi via SSH as described in the previous section.
  4. Edit the /etc/xrdp/startwm.sh file using a text editor like nano: sudo nano /etc/xrdp/startwm.sh.
  5. Find the line that starts with #!/bin/bash and add unset SESSION_MANAGER below it. Save and exit the file.
  6. Restart xrdp by running sudo service xrdp restart.

On Your Mac

  1. Install an RDP client like Microsoft Remote Desktop or iRDP Viewer from the App Store. We’ll use Microsoft Remote Desktop in this example.
  2. Open Microsoft Remote Desktop and click “Add PC” to create a new connection. Enter your Raspberry Pi’s IP address, username (pi), and password in the appropriate fields.
  3. Click “Options” to configure the display settings for the remote session. Set the resolution and color depth according to your preferences.
  4. Click “Save” to save the connection settings and connect by clicking “Connect”. You should now be able to see and interact with your Raspberry Pi’s graphical interface from your Mac!

Conclusion

With just a few simple steps, you can set up remote access to your Raspberry Pi from your Mac using SSH and RDP. These methods allow you to manage your projects from anywhere in the world without ever having to touch your device. Now you can work on your Raspberry Pi projects from the comfort of your own couch or while on vacation!

Happy remote hacking!