How to enable SSH on Debian 13

This blog post will show you how to enable SSH on Debian 13. SSH or Secure Shell Access is a network protocol that enables secure remote access over an insecure network. SSH sets up a remote, encrypted connection between machines and also enables SSH tunneling. In the following paragraphs, we will explain in more detail how SSH works, how it can be installed, and how it can be configured properly.

Installing and enabling SSH access is a straightforward process that may take up to 10 minutes. Let’s get things done!

Prerequisites

  • A server running Debian 13 OS
  • User privileges: root or non-root user with sudo privileges

Update the system

We assume that you have a fresh installation of Debian 13 OS, and before we start to install anything on the server, we will update the system packages to their latest version available. To do that, execute the following command on your terminal:

sudo apt update -y && sudo apt upgrade -y

Install OpenSSH server

OpenSSH server is a crucial component of the OpenSSH suite, which provides a secure and encrypted connection between two machines remotely. OpenSSH is a free and open-source version of the SSH protocol, and is often referred to as sshd. To install the OpenSSH server, execute the command below:

sudo apt install openssh-server -y

Next, start and enable the SSH server for automatic start on system boot by executing the following command:

sudo systemctl start ssh && sudo systemctl enable ssh

To check the status of the server, execute the command below:

sudo systemctl status ssh

You should get output similar to this:

root@host:~# sudo systemctl status ssh
● ssh.service - OpenBSD Secure Shell server
Loaded: loaded (/usr/lib/systemd/system/ssh.service; enabled; preset: enabled)
Active: active (running) since Sun 2025-08-10 04:16:30 CDT; 1min 21s ago
Invocation: e44d314de61f422ba35b5e0179af90a3
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 27460 (sshd)
Tasks: 1 (limit: 4640)
Memory: 1.3M (peak: 2.1M)
CPU: 83ms
CGroup: /system.slice/ssh.service
└─27460 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"

Aug 10 04:16:30 host.test.vps systemd[1]: Starting ssh.service - OpenBSD Secure Shell server...
Aug 10 04:16:30 host.test.vps sshd[27460]: Server listening on 0.0.0.0 port 22.
Aug 10 04:16:30 host.test.vps sshd[27460]: Server listening on :: port 22.
Aug 10 04:16:30 host.test.vps systemd[1]: Started ssh.service - OpenBSD Secure Shell server.

Besides the status of the service, we can also check if the OpenSSH server is running by checking its port number, which by default is port 22. Execute the following command to check if SSH is working on port 22:

netstat -tunlp | grep ssh

You should get the following output:

root@host:~# netstat -tunlp | grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 27460/sshd: /usr/sb
tcp6 0 0 :::22 :::* LISTEN 27460/sshd: /usr/sb

How to secure the OpenSSH server?

Securing the OpenSSH server is the most important action after its installation. Since everyone knows that the default port is port number 22, it can be easily attacked, and if the root password is not strong enough, the server can be easily hacked. To prevent this, let’s first change the default port 22. To do that, open the OpenSSH configuration file /etc/ssh/sshd_config, where all configuration parameters are stored.

Find this part #Port 22, uncomment i,t and change the number, for example, to 6022. Save the file, close it, and restart the SSH service.

sudo systemctl restart ssh

Next, we need to open port 6022 in the firewall using iptables. To do that, execute the command below:

iptables -A INPUT -s yourserverIP/24 -m state --state NEW -p tcp --dport 6022 -j ACCEPT

Once this is done, we need to permit root login and enable password authentication. To do that, open the file /etc/ssh/sshd_config again and adjust these lines of code to look like this:

PermitRootLogin yes

PasswordAuthentication yes

Now let’s check again the SSH port number with the following command:

netstat -tunlp | grep ssh

As you can see, the port number is changed, and the output looks similar to this:

root@host:~# netstat -tunlp | grep ssh
tcp 0 0 0.0.0.0:6022 0.0.0.0:* LISTEN 27703/sshd: /usr/sb
tcp6 0 0 :::6022 :::* LISTEN 27703/sshd: /usr/sb

To connect to the server via SSH from the command line, you can use the following command:

ssh root@yourserverIP -p 6022

Conclusion

That’s it. You learned how to enable SSH on Debian 13, including the installation and configuration previously.

If you have difficulties with this, our Linux admins will help you. Sign up for one of our monthly server management or per-incident server support plans and submit a support ticket.

PS. If you liked this post about enabling SSH on Debian 13, please share it with your friends on social networks or leave a comment below. Thank you.

Leave a Reply

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