Raspberry Pi

How to enable SSH in Raspberry Pi

The Secure shell or commonly known as the SSH is the protocol by which we can connect the one machine or a server from another machine. It has to make sure that the SSH is installed and enabled on both machines, the client machine as well as the host machine. From the host machine, we can access the client machine and manage the client machine remotely by using the terminal.

The SSH is mostly used to communicate between a local Linux machine to a remote Linux host, in this write-up, we will learn how to enable the SSH on the Raspberry Pi operating system.

How to install the SSH on Raspberry Pi

The Raspberry Pi is a Debian-based operating system, so the installation of SSH on Raspberry Pi is similar to any other Debian-based distribution. We will first, update the repository of the Raspberry Pi OS using the command:

$ sudo apt update

After making sure all the packages are up to date, we will proceed towards the installation of the SSH. The SSH is usually pre-installed on Raspberry Pi but if it is not installed, then we can install it using the command:

$ sudo apt install openssh-server -y

The SSH protocol has been successfully installed.

How to enable the SSH protocol on Raspberry Pi

After the installation of the SSH protocol, we will validate the status of the SSH protocol by using the command of systemctl:

$ sudo systemctl status ssh

The service is in running status, so we will enable it by using the command:

$ sudo systemctl enable ssh

The service of the SSH has been enabled and in the same way, make sure the SSH is installed and enabled on the machine you are going to access.

How to connect the remote machine using the SSH in Raspberry Pi

To connect with the remote machine, we first should know the IP address of that machine. To know the IP address, simply run the command mentioned below:

$ ip a

The IP address of remote machine is 192.168.18.154 and the general syntax of connecting with the remote machine using SSH is:

$ ssh [user]@[IP-address-of-the-machine]

In the above syntax, using the ssh keyword we can connect any machine, for example, in our case, “pi” is the user and 192.168.18.154 is the IP address of that user. We will use the command in our machine’s terminal:

$ ssh pi@192.168.18.154

When you are connecting to any machine first time, it will ask permission for proceeding the connection with this newly Linux machine, allow it by typing “yes”:

It will ask the password, enter the password of the user, just provide password of the machine you are accessing:

List down the contents of the remote machine in order to verify the connection:

$ ls

We can terminate this connection with the client machine through ssh by using the command:

$ logout

Conclusion

The SSH also known as Secure Shell Protocol which is used to access the remote machine for various purposes, such as managing and maintaining the servers. It is much more secure compared to telnet. Since Raspberry Pi OS is a Linux based operating system, we can install and configure SSH on it quite easily. In this write-up, we have discussed the method of installation of the SSH in Raspberry Pi and also learn the procedure to make SSH enable in Raspberry Pi.

About the author

Hammad Zahid

I'm an Engineering graduate and my passion for IT has brought me to Linux. Now here I'm learning and sharing my knowledge with the world.