Thursday, 20 April 2017

How to control your Raspberry Pi with SSH from your computer

So you have purchased and installed your Raspberry Pi (if this is not done, what do you expect? Go for it! )

But you have no screen and you want to control it from your computer ? Do not panic, we will help!

What is SSH?


Before seeing how to control the Raspberry Pi with SSH, let's see exactly what SSH is.

SSH (for Secure SHell) refers to both software and a computer communication protocol . This protocol has also the peculiarity of being entirely encrypted.  You can execute all command  via SSH. It will be completely secret!

Main aim of SSH for allowing the remote control of a machine through a command line interface.

Today, SSH is mainly used through the free OpenSSH implementation that is present in most Linux distributions.

How does SSH work?


We will not go into cryptographic and other details here. We will just give you a quick overview about this. You can understand how to use SSH.

In general, SSH allows to connect remotely on a machine using a user account by machine .

The computer that needs to connect to the remote machine. It will provide with the name of the user to use and the password . It is possible in some cases to use a set of certificates on the computer and the remote machine , thus making it possible to obtain a secure connection without having to type a password. 

By default, SSH provides only a command line takeover. It is possible in some cases to add a graphical interface but this is a more complex method than we will not see here.

Install SSH to take control of your Raspberry Pi

Now that we know a little more about SSH, let's see how to set it up to control your Raspberry Pi!

 You should know that the installation of SSH is split into two parts. 

You will need one side of an SSH server on your Raspberry Pi and another one of an SSH client on your computer . 

The first will receive the commands to launch while the second will send them.

Enable the SSH server on your Raspberry Pi


SSH is installed on the Raspberry Pi, but is disabled for security reasons. The first thing will do enable SSH on your Raspberry Pi.

Simply plugged  the MicroSD card of your Raspberry Pi into your computer and go to the card,and create a file named ssh in the folder /boot/.

Once done, all you have to do and  put your SD card back into your Raspberry Pi.After that  SSH will be activated the next time you start it.

Note that now SSH is enabled, any account created on your Raspberry Pi can be used to connect via SSH. So make sure to use strong passwords (including changing the user's default password pi)!

Install the SSH client on your computer


This time, no good news, a priori you do not have an SSH client installed on your premises. So there are two possibilities (actually three, but if you have a mac you d├ębrouillerez alone), or you have a Windows computer (and we wonder why b), or you have a Linux ( And women - or men for that matter - throw themselves at your feet, your enemies fear you, and your friends envy you. So we will see the installation of an SSH client for both cases.

Installing an SSH client on Linux

If you are on Linux, To install an SSH client, it's simple and  run this  following command:

Sudo apt-get update & sudo apt-get install openssh-client
You see, everything is simpler under Linux !

Installing an SSH Client for Windows

You made the wrong choice but it will be much forgiving.

You will have to install the software Putty which is an SSH client and TelNet.

You can find this excellent tool on the dedicated website.
Interestingly, Putty is part of this software that does not require installation!

Use SSH to connect to the Raspberry Pi


Now that we have installed a server and an SSH client and  we have to do is use all them.
There are  two different methods depending on whether you are under Linux or Windows.

Basically, the principle remains same and use the SSH client to communicate with the server and using the server address, a user name and the associated password.

Use SSH with Linux

As always with Linux, you only need a single command line to connect to the Raspberry Pi.

Ssh user @ address_ip_or_url_server
Of course, you will have to replace "user" with the name of the user with whom you want to connect and "ip_address_or_server_id" by the server IP or URL if it has one.

Once you have entered the user account password (which, for security reasons, does not appear when you type it), you will be connected to the Raspberry Pi terminal and all commands. To exit SSH you just need to use the command "exit".

No comments:

Post a Comment