How to enable SSH server in Debian 12

Endrit Qerreti

Endrit Qerreti

In this tutorial, you will learn how to enable SSH server on your Debian 12 machine.

You can easily connect to your server using SSH protocol, that's because the server has already the openssh server package installed and configured.

However, when it comes to Debian 12 Desktop, the ssh server is not enabled by default, which means in order to be able to connect to your Debian 12 machine via SSH, you must have ssh server enabled.

Enable SSH Server in Debian 12

Enabling SSH server in Debian 12 is very simple, and it can be done easily by installing the SSH server package openssh-server.

Step 1 - Update your system

Before we begin with this tutorial, ensure that your Debian 12 machine doesn't have outdated packages on it.

To check for updates in Debian 12, and proceed to upgrade them automatically after, simply run the command below.

sudo apt update && apt upgrade -y

Step 2 - Install SSH Server

Your Debian 12 machine should be updated now, and you can proceed to install SSH server.

To install SSH server, is quite simple, and all you have to do is install the ssh server package openssh-server.

openssh-server can be easily installed in Debian 12, as openssh-server is available in the default repositories of Debian 12, which means to install SSH server on Debian, you can do so by running the command below.

sudo apt install openssh-server -y

💡
Note: The command above, will install openssh-server, and to be able to connect to this machine where we are installing the SSH server, you must have SSH client installed openssh-client. If you don't have SSH client installed, then you can easily install it with sudo apt install openssh-client

Step 3 - Enable SSH Server

Now that SSH server is installed in your Debian 12 machine, all you have to do now is connect to the SSH server.

The ssh server will start automatically once installed, verify that the SSH server is running.

sudo systemctl status ssh

If the SSH server is not running, then you can start SSH server by running the command below.

sudo systemctl start ssh

The SSH server is now up and running, and you can proceed to the next step, to connect to your machine via SSH.

Step 4 - Connect to SSH Server

The SSH Server is now running on the machine where we installed the SSH server, which means we can now connect to this machine via the IP address.

To find the IP address, is quite simple, and you can do so by using the ip command.

ip a

The IP address should look like this

192.168.0.1

Now once you know the IP address, proceed to connect to the SSH Server, via the command below.

ssh username@ip-address
💡
Note: replace username and ip-address with the username and IP address of the SSH server.

For example, let's say that we want to connect to our SSH server under the username owlhowto and the IP address 192.168.0.1, we can easily do so by using the following config.

ssh owlhowto@192.168.0.1

Step 5 - Manage SSH Server

Here are some useful commands that you should know, that can help you manage your SSH server.

Enable SSH server process

By default SSH server won't start automatically once you boot up your machine, if you want the SSH server to automatically start, then you need to enable the SSH service.

To do so, simply run the command below.

sudo systemctl enable ssh

Start SSH Server

To start SSH server manually, you can do so by using the systemctl command.

sudo systemctl start ssh

Restart SSH server

To restart SSH server, run the following.

sudo systemctl restart ssh

Stop SSH Server

To stop the SSH server, you can easily do so by running the command below.

sudo systemctl stop ssh

Conclusion

In this tutorial, you learned how to enable the SSH server on Debian 12, so that you are able to connect to Debian 12 by using the Secure Shell SSH protocol.