Debian

Enable SSH on Debian 10

You can use SSH to access to your Debian 10 server or desktop remotely. You can install new software packages, configure them, monitor your Debian 10 server or desktop remotely via SSH.

In this article, I am going to show you how you enable SSH on Debian 10 and connect to your Debian 10 machine remotely via SSH. So, let’s get started.

Installing SSH Server on Debian 10:

On Debian 10, the SSH server is provided by the package openssh-server. You can install the OpenSSH server from the official package repository of Debian 10 very easily using the APT package manager.

First, open a Terminal and run the following command to update the APT package repository cache.

$ sudo apt update

The APT package repository cache should be updated.

Now, install openssh-server package with the following command.

$ sudo apt install openssh-server

Now, press Y and press <Enter> to confirm the installation.

The openssh-server package should be installed.

Now, you can check whether the SSH service is running with the following command:

$ sudo systemctl status ssh

As you can see, the SSH service is not active. It is not running. But it is enabled. Which means, the SSH service will automatically start on boot. So, to start the SSH service, all you have to do is restart your computer.

If you don’t want to restart your computer right now, you can start the SSH service manually with the following command:

$ sudo systemctl start ssh

Now, check whether the SSH service is running with the following command:

$ sudo systemctl status ssh

As you can see, the SSH service is active or running. Now, you can connect to this computer remotely via SSH.

Adding and Removing SSH Service from System Startup:

On Debian 10, the default behavior of the SSH service is to start automatically on boot.

If you don’t want the SSH service to start automatically on boot, rather you want to start the SSH service manually when you need, then you can remove it from the system startup with the following command.

$ sudo systemctl disable ssh

If you later change your mind and want to start the SSH service on boot, then you can add the SSH service to the system startup with the following command:

$ sudo systemctl enable ssh

Connecting to Debian 10 Machine Remotely via SSH:

Now, to connect to the SSH server, you need the IP address or hostname/domain name of the Debian 10 machine where you just installed the SSH server. You also need to know the login username and the login password of the Debian 10 machine that you want to connect to.

To find the IP address of the Debian 10 machine which you want to connect to remotely, run the following command on that machine.

$ ip a

As you can see, the IP address of my Debian 10 desktop is 192.168.21.134. It will be different for you. So, make sure to replace it with yours from now on.

If the Debian 10 machine that you’re trying to connect via SSH is hosted on the cloud (VPS), then you may have a DNS resolvable hostname or domain name which you can use instead of the IP address. To find the hostname of the VPS, run the following command on the VPS.

$ hostname

An example output is given as follows.

If you don’t know the login username of your Debian 10 machine, then you can run the following command on that machine to find the username.

$ whoami

The username should be printed on the terminal. Remember it.

In order to connect to the Debian 10 machine remotely via SSH, the client computer must have the SSH client program installed on it.

If the client is an Ubuntu/Debian machine, then you can install the SSH client programs with the following commands:

$ sudo apt update
$ sudo apt install openssh-client

If the client is an RHEL/CentOS machine, then you can install the SSH client programs with the following commands:

$ sudo yum install openssh-clients

Now, to connect to the Debian 10 remote machine via SSH, run the following command from the client machine:

$ ssh USERNAME@IP_ADDRESS

Or

$ ssh USERNAME@HOSTNAME

In my case, the command is:

$ ssh shovon@192.168.21.134

You will see the following prompt the first time you try to connect to your Debian 10 machine via SSH. Just type in yes and press <Enter> to continue.

You will see the following prompt the first time you try to connect to your Debian 10 machine via SSH. Just type in yes and press <Enter> to continue.

You should be connected.

Now, you can run any command you want to install new software packages, configure different services, or monitor the Debian 10 machine remotely. The possibilities are limitless.

Once you’re done with your work, you can close the SSH session with the following command:

$ exit

So, that’s how you enable SSH on Debian 10 and connect to your Debian 10 machine remotely via SSH. Thanks for reading this article.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.