Remotely Access Your Raspberry Pi from Anywhere Using Secure Shell (SSH) Protocol

Learn how to connect to your Raspberry Pi remotely using the secure shell protocol and take advantage of its computing power and resources without being physically present. …


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 connect to your Raspberry Pi remotely using the secure shell protocol and take advantage of its computing power and resources without being physically present.

Raspberry Pi is a popular single-board computer that runs Linux operating system. It is a low-cost, credit-card sized device with built-in Wi-Fi and Ethernet connectivity, allowing you to use it for various projects. One of the most useful features of Raspberry Pi is its ability to access remotely over SSH (Secure Shell) protocol. This allows you to manage your Raspberry Pi from anywhere in the world without having to be physically present.

Enable SSH on Your Raspberry Pi

To connect to your Raspberry Pi via SSH, you need to enable SSH on it first. By default, SSH is disabled on Raspberry Pi OS (Raspbian). Follow these steps to enable it:

  1. Open the terminal and navigate to the directory where config.txt file is located:
    cd /boot/
    
  2. Open the config.txt file with a text editor of your choice, such as nano:
    sudo nano config.txt
    
  3. Add this line at the end of the file to enable SSH:
    ssh=1
    
  4. Save and close the file.
  5. Reboot your Raspberry Pi for the changes to take effect:
    sudo reboot
    

Find Your Raspberry Pi’s IP Address

To connect to your Raspberry Pi via SSH, you need to know its IP address on the network. You can find it in different ways depending on your operating system and network setup:

  • If you are using a router with DHCP server, check your router’s admin interface or use a network scanner tool like nmap to scan for devices on the network and find your Raspberry Pi’s IP address.
  • If you have assigned a static IP address to your Raspberry Pi, you already know its IP address.
  • If your Raspberry Pi is connected directly to your computer via Ethernet or USB-to-Ethernet adapter, you can find the IP address by running ifconfig command on your Raspberry Pi:
    ifconfig
    

    Look for eth0 or wlan0 interface and note down its inet address.

Connect to Your Raspberry Pi via SSH

Now that you have enabled SSH on your Raspberry Pi and know its IP address, it’s time to connect to it. Open a terminal on your local computer (Mac or Linux) or install an SSH client like PuTTY (Windows). Run the following command to connect:

ssh pi@<your_raspberry_pi_ip_address>

Replace <your_raspberry_pi_ip_address> with the IP address you found earlier.

When connecting for the first time, you might see a warning about the authenticity of the host. Type yes to continue connecting.

You will be prompted to enter the password for the default user account on Raspberry Pi (pi). The default password is raspberry. After entering the correct password, you are now connected to your Raspberry Pi via SSH!

Using SSH

Now that you are connected to your Raspberry Pi via SSH, you can run commands just like if you were sitting in front of it. For example, you can update packages:

sudo apt-get update && sudo apt-get upgrade

Or check the system status:

sudo systemctl status

You can transfer files to and from your Raspberry Pi using scp command (Secure Copy Protocol). For example, to copy a file example.txt from your local computer to your Raspberry Pi’s home directory:

scp example.txt pi@<your_raspberry_pi_ip_address>:~/

To copy a file from your Raspberry Pi to your local computer:

scp pi@<your_raspberry_pi_ip_address>:~/example.txt .

Don’t forget the trailing dot (.) in the second command, which specifies the current directory on your local computer.

You can also use graphical remote desktop applications like VNC or RDP to remotely access your Raspberry Pi and interact with its GUI. This is useful for running graphical applications that require a display. However, SSH is usually more convenient for managing files and running command-line tasks.

In conclusion, connecting to your Raspberry Pi via SSH is an essential skill for any maker or developer. It allows you to manage your device remotely, automate tasks, and use its computing power from anywhere in the world. Once you enable SSH on your Raspberry Pi, finding its IP address and connecting to it using an SSH client is straightforward. Now go ahead and start building something amazing!