Developing applications for your Raspberry PI, you will often need to connect to the Raspberry PI from another computer to deploy code or run tests etc. The best way to do this is via SSH.
In this tutorial, I will provide instructions on how to enable SSH on your Raspberry Pi, which will enable you to remotely access the Raspberry Pi via SSH.
I will not provide a detailed discussion of the in depth discussion of SSH, but I will give you enough information to enable you to connect to your raspberry pi from another computer.
What is SSH
Secure Shell (SSH) is a command interface and protocol to enable the secure access to a remote computer. It is the tool of choice for Network Administrators, developers and programmers to access Linux Servers, Desktops and Devices remotely.
SSH essentially enables you to connect to your Raspberry Pi from another computer and enable you to execute Linux based commands as if you are actually logged onto the computer itself.
This type of approach is handy if you want to code on the Pi from the comfort of your laptop. Using this approach you don’t need to connect your keyboard, mouse or TV to your raspberry pi, all you need to do is connect your raspberry pi to the network, and you can connect to it.
Although this steps outlined here, are designed to work with raspberry pi, it is important to note that they can be used for any Debian based Linux distribution.
For this tutorial I have made the following assumptions;
- You are confident with the basics of using the Raspberry
Pi,and are able to boot your Pi to the command line
- Your PI operating system is Raspbian
- Your PI is already connected to your network
- you want to connect via SSH to your Pi from another Linux based computer.
The first thing we need to do once your PI has started
This command will show all the relevant network configuration for your PI. Your IP will displayed as
inet addr. Make a note of this as it will be relevant later.
Enable SSH with Raspberry PI Configuration
If you are using the Raspbian Desktop you can easily configure ssh using the Raspberry Pi Configuration utility. Available at clicking the Raspberry Pi Logo in the top left hand corner:
Raspberry Pi Logo –> Preferences –> Raspberry Pi Configuration –> Interfaces
Then select enable on SSH
Install SSH on Raspberry PI using Terminal
Raspbian already has SSH prepackaged, however I am going to err on the side of caution and suggest we just install it anyway. If you are using a distro that does not have it it preinstalled
After the install is complete we’ll start the SSH Service
You are also able to stop and restart this service in a similar way i.e.
The one thing I like to do ensure the SSH service starts every time you boot the PI is use the following command which will update a config setting
You can now restart your PI and disconnect it from your Keyboard & Mouse and television if you choose but leave it connected to you network.
Open a terminal window on your linux desktop and connect to your PI using the IP address we retrieved earlier. Remembering the default username = pi and password = raspberry
Access Raspberry Pi using SSH
You can now start any commands you choose to the PI, and these commands will be executed directly on the PI.
To terminate your SSH session after you have finished simply type
How to access SSH from Windows
The above commands and processes were based on the assumption you were accessing the raspberry pi via ssh via another Linux or Mac OS system.
In order to untilise SSH on windows machines historically required making use of applications like PuTTY etc. However, since Windows 10’s April 2018 Update, a built-in SSH client is now enabled by default!
How to Use Windows 10 SSH Client
You can now use the SSH client by running the
ssh command. This works in either a PowerShell window or a Command Prompt window, so use whichever you prefer.
To quickly open a PowerShell window, right-click the Start button or press Windows+X and choose “Windows PowerShell” from the menu.
To view the syntax of the ssh command:
To access your raspberry pi using ssh on Windows is similar to the above. All you need to do is either open a cmd window or a powershell window and using the ssh command with pi@ and the IP address you want to connect to.
The biggest benefit of being able to access your Raspberry Pi via SSH is that you don’t need to have the Pi connected to any screen, keyboards or mice. You Pi effectively becomes a little quiet, low energy consuming, low noise server/computer. As long as it has a network connection you can access it.
Denizon's product line successfully integrate IoT, Artificial Intelligence and Blockchain technology to enable efficient, productive, secure and scalable solutions to help organisations address increasing energy demands, ecological impact and Health & Safety concerns of their staff.