SSH for remote access to your Raspberry Pi

SSH for remote access to your Raspberry Pi

Are you still connecting your Raspberry Pi with a monitor, keyboard and mouse? Any linux-based operating systems, like the Raspberry Pi, are designed to be accessed remotely since its was originally used for servers. There is no need to use it as a local machine only because you can use SSH in another computer to gain access to it as long both are in the same network.

Raspberry Pi connected to a monitor via HDMI

I will show you how.

You can however access your Raspberry Pi from anywhere in the world with an internet connection but some special configurations must be done. More on that later.

Enable the remote access

Before starting a new setup, be sure to make an update to the repositories in your Raspberry Pi.

sudo apt-get update

In order to enable SSH, we need to access Raspberry Pi Software Configuration Tool. Open a new Terminal window (also called LXTerminal) and type:

sudo raspi-config
Terminal on Raspberry Pi to open raspi-config or Raspberry Pi Software Configuration Tool

A blue window with a gray menu will appear. Select with the navigation arrows “Interfacing Options” and then “SSH”. Click ‘yes' when you are prompted with the message “Would you like the SSH server to be enabled?”; on the image below you will see ‘Sí' because my Raspberry Pi is set in Spanish. A message window will appear stating “The SSH server is enabled”. By this far, you can access your Raspberry Pi remotely. Click on ‘Finish' to exit “Raspberry Pi Software Configuration Tool”.

Before testing the SSH server, make sure to restart the service:

sudo service ssh restart

Testing

Now, let's test that everything runs as it should. First you need to know the IP address of your Raspberry Pi. Open the terminal and type:

ifconfig

If your Raspberry Pi is connected through an ethernet wire, then find the section ‘eth0'. If your Raspberry Pi is connected through a Wi-Fi connection, then find ‘wlan0'.

Write down on your cellphone or in a piece of paper. You will need the IP address (similar to 192.168.1.x) and the MAC address (similar to b8:27:eb:e3:xx:xx). You will need it later for DHCP.

The default SSH port is going to be 22 by default. If you use Port Forwarding, this number may be different. If you haven't configured any user yet, then ‘pi‘ will be the user registered in your Raspberry Pi by default; in that case, the password by default is ‘raspberry‘.

For testing in any operating system (OS), you will need this information as described earlier.

  • IP Address:port number, example: 192.168.1.10:22.
  • User / password, example: pi / raspberry.

SSH on Windows

You will need a SSH client for this operation, as this feature doesn't come natively in Windows. I use Putty which is free to use and you can download it from here.

Put the hostname or IP address of your Raspberry Pi and type 22 on the port textbox. Make sure ‘SSH‘ is selected and clich on ‘open'.

Tip: I recommend to write a name on the box “Saved Sessions” and click on ‘Save'. Next time you open Putty, click on the name of the session, then ‘load' and the login information will be there, thus you don't have to type everything again.

SSH on macOS

On Mac open Spotlight by pressing Cmd + space, and then type ‘Terminal‘. Use the following line of code:

ssh user@ip

where ssh opens a SSH session between the host (your Raspberry Pi) and the client (your Mac).

The Terminal on macOS, which is used to login to Raspberry Pi with SSH

You're in!

Not default port?

In case that you are not using the default port 22, then you will need to specify it using:

-p (port)

If the port that you are using is, let's say 12345, then you will need to type the following command.

ssh user@ip -p 12345

You can check similar questions about this topic on the Ubuntu forums!

Configure DHCP

This step will ensure that the IP of your Rapsberry Pi remains the same, all the time. You will need the password of your router configuration, not the “Wi-Fi” password.

Port Forwarding for ‘truely' remote access

Would you like to access your Rapsberry Pi from anywhere in the world? First, you need a designated port from your internet service provider (ISP) to grant access to your router.

You have reached this far!

Thank you for reading the blog post. Your comments and suggestions are welcomed. At the bottom of this page, leave a message or just say hi! The whole team of techZorro will appreciate it. Don't forget to share it on social media as well.

techZorro’s Index of Content

Click on the following link to browse likewise content in the blog in techZorro. This index will help you see what you are looking for in a bird’s eye view.

techZorro's Newsletter!

If you enjoyed this blog post, please subscribe to techZorro’s newsletter so you don’t miss any future blog posts!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.