How to Enable SSH Server in Debian 11

3030
Share:
how-to-enable-ssh-server-in-debian-11

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line, login, and remote command execution, but any network service can be secured with SSH.

By default, Debian 11 installation should also include SSH server. The most widely used SSH server in Linux is OpenSSH, so we will use it for this article.

First, let's make sure that we have OpenSSH server installed. On your terminal, enter this command:

$ sudo apt list openssh-server.

If it's installed, the response should be like below:

OpenSSH Server Installed

Otherwise, you should install it using this command:

$ sudo apt install openssh-server

Next, let's check if it's enabled and running. To check if the server is running, type this command:

$ systemctl is-enabled ssh

If it's not enabled, let's enable it:

$ sudo systemctl enable ssh

Once the server is enabled, let's check whether it's active or not. Back to terminal and enter this command:

$ systemctl is-active ssh

Systemctl Check

If it responds with active, then we're good. Proceed to next part of this article: Connect SSH From Another Host.

Otherwise, if it responds with failed like my case, then let's figure out why it's failed.

Troubleshooting

Just like every systemd distributions, we could check a service's status by using this command:

$ systemctl status ssh

Systemctl Failed

We can see that our ssh service is failed with status code 255 (exception). Why is this happening? Most common reason for this issue is configuration error. Let's check if it's the case.

I know there are many Linux applications provide a built-in utility to check its configuration file validity. Luckily, this is also the case for OpenSSH. To check OpenSSH configuration file, we can use (-t) flag when running sshd command. Let's try it.

$ sudo sshd -t

SSHD Configuration Error

There you go. It seems that our OpenSSH configuration file is invalid. Let's fix it.

SSHD Configuration File

Let's put a comment (#) in the beginning of line 116.

Commented

Save the file and restart OpenSSH server.

$ sudo systemctl restart ssh

OpenSSH Running Fine

Voila! Now we've successfully activate OpenSSH server. Let's try to connect from remote system.

Connect SSH From Another Host

To connect with our Debian 11 host from another host, we'll use ssh command.

$ ssh [user]@[ip/domain]

For example, my Debian 11 system has IP 10.10.10.132. Here's the command I use when I want to connect with user ben.

$ ssh [email protected]

If this is your first time connecting between two hosts, it will ask for confirmation. Type "yes" followed by enter to continue connecting with remote host.

SSH Connected

Final Words

I hope that you now know how to enable SSH Server in Debian 11. If you run into any issues or have any feedback feel free to drop a comment below.


Tags Linux
Share:

0 comment

Leave a reply

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