A Step-by-Step Guide for Setting up Raspberry Pi Remote Access and File Sharing with your Computer or Mac

Learn how to connect your Raspberry Pi to your computer using SSH and Samba, allowing you to remotely access your Pi and share files between the two devices. …


Updated October 20, 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 connect your Raspberry Pi to your computer using SSH and Samba, allowing you to remotely access your Pi and share files between the two devices.

Raspberry Pi is a powerful, versatile single-board computer that has gained popularity in recent years for its ability to run various operating systems and perform diverse tasks such as web servers, home automation, media centers, and more. One of the most common uses for Raspberry Pi is remote access, which allows users to control their Pi from a distance using a separate device like a laptop or desktop computer. This can be achieved by setting up secure shell (SSH) and Samba on your Raspberry Pi. In this guide, we will cover how to connect a Raspberry Pi to a laptop using SSH and Samba for remote access and file sharing.

  1. Installing SSH: First, you need to install the SSH server on your Raspberry Pi. SSH (Secure Shell) is a protocol that allows secure access to a device remotely over a network. It provides encryption to protect sensitive data while also allowing users to execute commands and transfer files between devices. Follow these steps to install SSH:
  • Open the terminal on your Raspberry Pi by clicking on the Menu > Accessories > Terminal or pressing Ctrl + Alt + T.
  • Type sudo apt-get update and press Enter to update the package list.
  • Then, type sudo apt-get install ssh and press Enter again. This will install the SSH server on your Raspberry Pi.
  • After installation, type sudo systemctl enable ssh and press Enter to make sure SSH starts automatically when your Pi boots up.
  • Finally, type ifconfig in the terminal to obtain your Raspberry Pi’s IP address (look for “inet” under wlan0 or eth0). You will need this IP address to connect from your laptop later on.
  1. Connecting via SSH: Now that you have SSH installed, it’s time to connect your Raspberry Pi to your laptop using an SSH client like PuTTY (Windows) or Terminal (Mac/Linux). Follow these steps to establish a secure connection:
  • On Windows, download and install PuTTY from the official website: https://www.putty.org/
  • Launch PuTTY and enter your Raspberry Pi’s IP address in the “Host Name (or IP Address)” field.
  • Click “Open” to connect to your Pi. If this is your first time connecting, you may be prompted to add the SSH key fingerprint to your registry. Accept to continue.
  • Enter the default Raspberry Pi username (“pi”) and password (“raspberry”). You should now have remote access to your Pi’s terminal.

For Mac or Linux users using Terminal, simply type ssh pi@<ip address> in the command line, replacing <ip address> with your Raspberry Pi’s IP. Press Enter and enter your password when prompted.

  1. Setting up Samba: Samba is a protocol that allows you to share files between Windows, Linux, and macOS devices over a network. To set up Samba on your Raspberry Pi, follow these steps:
  • Open the terminal on your Pi and type sudo apt-get install samba samba-common-bin to download and install Samba.
  • Create a new directory for shared files by typing mkdir /home/pi/shared_folder. This will create a folder called “shared_folder” in the pi user’s home directory. You can replace “shared_folder” with any name you prefer.
  • Edit the Samba configuration file using a text editor like nano: sudo nano /etc/samba/smb.conf.
  • Add the following lines to the end of the file, replacing <share name> and <path to shared folder> with your desired share name and path (e.g., “shared_folder”):
[<share name>]
   path = <path to shared folder>
   browseable = yes
   read only = no
   guest ok = yes
   create mask = 0755
  • Save the file and exit the editor by pressing Ctrl + X, then Y, and Enter.
  • Restart Samba by typing sudo systemctl restart smbd.
  1. Connecting to your Raspberry Pi’s shared folder: Now that you have set up Samba, it’s time to connect to the shared folder from your laptop. Follow these steps for Windows and Mac/Linux users:
  • For Windows users using Explorer, open the network tab in File Explorer (press Win + E) and locate your Raspberry Pi by IP address or hostname (e.g., \\raspberrypi\shared_folder). Enter the default pi user password when prompted.
  • For Mac/Linux users, open Finder (Mac) or Nautilus (Linux) and navigate to “Connect to Server” in the Go menu. Type smb://<ip address>/<share name> in the URL field, replacing <ip address> with your Raspberry Pi’s IP and <share name> with the name you chose earlier (e.g., “shared_folder”). Enter the default pi user password when prompted.

That’s it! You have successfully connected your Raspberry Pi to a laptop using SSH and Samba for remote access and file sharing. Now you can remotely control your Pi from anywhere, and easily transfer files between devices.