Linux

How to Enable SSH on Debian 9 or 10?

Introduction

SSH is an acronym utilized for referring to Secure Shell or Secure Socket Shell. It serves as a network communication protocol that renders a secure way to access a system over an unsecured network. SSH can also be defined as the set of utilities that execute SSH protocol. It has been employed for connecting to a remote computer. It enables you to access files and further, perform administrative tasks. In this guide, we have come up with a tutorial that will make you learn how to enable SSH on Debian 9 (Stretch) or Debian 10 (Buster). Before you move on to the steps to enable SSH Debian, let us give you insights into what prerequisites you have to meet with first. 

Requirements

Mentioned following are the prerequisites that must be fulfilled to enable SSH Debian

  • You must have a Debian system that can serve as an SSH (Secure Shell) server.
  • You also need to have a Debian system that can serve as an SSH (Secure Shell) client. 
  • You need to have access to sudo privileges on Debian for each system.
  • You must acquire access to a command line (Ctrl-Alt-T).
  • You must have an apt package manager that generally comes by default. 

Follow the Steps to Enable SSH on Debian

You must make sure that you have a secure connection when you connect remotely. This is because the hacker gets the possibility to intercept usernames, passwords, and configuration files when the connection is not secured. It can further compromise the data protection of your server. Below are the principal five steps that will take you through the process of enabling SSH Debian while establishing a secure connection.

Step 1: Updating the Package Manager

You need to update the software repository list before you install the new software. To do this, enter the command –

sudo apt update
Steps to Enable SSH on Debian

Step 2: Installing SSH Server

Next, you need to run the following command on the system that serves as a server – 

sudo apt install openssh-server
Steps to Enable SSH on Debian

You need to enter the password once the system prompts. Further, you can press Y to continue the installation process. Your system can also display the output stating that the most current version is already installed (if that is the case).

Moreover, you can confirm the SSH service status by running the following command – 

sudo systemctl status ssh
Steps to Enable SSH on Debian

This will let the system confirm that your SSH service is running.

Step 3: Starting and Stopping the SSH Server

The SSH (Secure Shell) is responsible for controlling the connection. So, it is quite convenient to know about the starting and stopping of the service. 

To stop the SSH host server, enter the command –

sudo service ssh stop
Steps to Enable SSH on Debian

After this when you check the status of the service, your system will indicate that the SSH (Secure Shell) is inactive. Further, the system also indicates the precise date and time the SSH service stopped. 

To initiate the SSH service, enter the command – 

sudo service ssh start
Steps to Enable SSH on Debian

Moreover, when you stop the SSH service, it can only last until the next reboot. So, to turn off the SSH service indefinitely, you need to enter the command – 

sudo systemctl disable ssh
Steps to Enable SSH on Debian

Furthermore, you can re-enable the SSH service just by replacing the disable syntax with enable.

Step 4: Acquiring Server IP Address

In case you configure your server locally, the IP address can be easily displayed from a terminal window with the help of the following command – 

ip a
Steps to Enable SSH on Debian

Note that the IP address comes in a format like this –

176.103.61.97

On the other side, if you connect to an already configured server, you are required to acquire the IP address from the server’s administrator. Alternatively, you can have the possibility to log in while employing the server’s hostname or domain name.

Step 5: Installing SSH Client Service (Optional)

There can be two possibilities in this step. The first is you are attempting to connect a server that has already been set up. The second is that you have come up here by completing the previous steps on your server. In either case, you need to open a terminal window on your client system. Then, update the package list using the following command – 

sudo apt-get update
Steps to Enable SSH on Debian

You must note that most Linux systems come with the SSH client that is installed by default in them. If this is not the case with your system, you can enter the command – 

sudo apt install openssh-client
Steps to Enable SSH on Debian

SSH is an acronym utilized for referring to Secure Shell or Secure Socket Shell. It serves as a network communication protocol that renders a secure way to access a system over an unsecured network

Connecting to a Server Using SSH

Moving on, you can connect to the server with a secure shell by utilizing the following command- 

ssh UserName@IPAddressOrHostname
Connecting to a Server Using SSH

You need to substitute the UserName with the username of an entitled user on the server. Following the @ sign, you need to make use of the IP address that you have obtained in Step 4. Also, you can employ the domain name instead. Further, you can also specify a hostname in case your server is configured to utilize one.

Moreover, the system can prompt you for confirmation if you connect to a server for the first time. In this case, you need to type ‘yes‘ and then ‘enter‘.

Next, the remote system will require you to enter the password. You need to enter the password that is committed to the username you utilize. After this, you will notice your command prompt changing to username@hostname. This will indicate that the commands you run are going to execute on the remote server.

Make a note that you have to install a third-party utility such as PuTTY if you wish to connect from a Windows system. 

Firewall and Security Settings

Debian makes use of the UFW firewall by default. It can interfere with secure shell traffic. To enable SSH Debian access, enter the command – 

sudo ufw allow ssh
Firewall and Security Settings

Make a note here that the SSH traffic goes through port 22

Further, if you wish to execute the essential security measures, you can utilize your firewall application (or router configuration) to set up port forwarding. In this case, you are required to refer to your documentation for details. The strategy that is employed here is to move the traffic requests coming in forward towards port 22. And, then these requests go to the IP address of the machine behind the firewall.

Also, you get the possibility to configure your firewall or router to accept SSH traffic on a different port. It will help you to restrict access to only those users who are aware of the correct port. Thus, changing the port can enable you to limit unauthorized connections.

Also Read: How to Enable SSH on Ubuntu?

Conclusion

If you follow the steps outlined in this guide, you will be able to successfully enable an SSH connection on Debian. Afterward, you can connect to your remote host securely. And, further, you can continue to run and manage your servers in a safe environment. Moreover, if you face any difficulty in the Debian SSH server or get stuck in any of the above-explained steps to install SSH server Debian, you can connect with us. We, along with our Hostbillo’s experts, are available via various mediums round-the-clock to resolve any issue you might face. 

Arpit Saini

He is the Chief Technology Officer at Hostbillo Hosting Solution and also follows a passion to break complex tech topics into practical and easy-to-understand articles. He loves to write about Web Hosting, Software, Virtualization, Cloud Computing, and much more.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

[sc name="footer"][/sc]