In this tutorial we demonstrate the steps required by a Linux systems admin to install and enable SSH server on Debian 11 Bullseye Linux.
SSH is a network protocol used to administer a server remotely via command line. It’s the Linux alternative protocol to the RDP used in Windows systems.
Here’s what we are going to follow in this article:
- Installing OpenSSH service
- Checking SSH Server status
- Enabling SSH Server on system startup
- Troubleshooting Common Issues
1. Installing OpenSSH Service
To install SSH on Debian 11 execute the following commands on your server:
root@localhost:~$ apt update
Since the SSH server is not installed by default, use the following command to do so:
root@locahost:~$ apt install openssh-server
Enter “Y” once prompted to confirm the installation.
2. Checking SSH Server status
Upon installation’s completion, SSH service should be automatically started. To verify this run the following command:
root@localhost:~$ systemctl status ssh
If the SSH service is running, you should see the following on screen:
Loaded: loaded (/lib/systemd/system/ssh.service; enabled; [...] Active: active (running) since [...]
Pres “q” or “Ctrl-C” to exit and return to the shell.
3. Enabling SSH Server on system startup
To ensure the SSH service is started upon server’s startup, execute the following command:
root@localhost:~$ systemctl enable ssh
You are done! You should be able now to remotely connect on your Debian 11 server via SSH.
Below we are providing the solution for the most common problems you may encounter when trying to install or enable the SSH service.
4. Troubleshooting Common Issues
If you have installed Debian 11 via a network ISO, them during installation you may have answered “No” to the question “Use a network mirror?”. If this is the case, then it means your system was installed without a mirror, or perhaps you didn’t have an active internet connection during installation.
This will cause an incomplete sources.list where repositories for Debian 11 updates and security fixes are not included.
You have to configure a mirror in order to be able to properly install the openssh-server package. Follow these steps:
4.1. Edit the file sources.list as follows:
root@localhost:~$ nano /etc/sources.list
4.2. Include the following 2 lines at the top of the file:
deb http://ftp.debian.org/debian/ buster main contrib non-free
deb-src http://ftp.debian.org/debian/ buster main contrib non-free
4.3. Save and exit the file
4.4. Run the following command to update your system with the newly added repositories:
root@localhost:~$ apt update
Once the update is completed, you can follow the steps in this article from the beginning, starting from the command “apt install openssh-server“.