Jul 19, 2019 10:00 AM

Installing SSH on Debian/Ubuntu

In this article I will explain how to install an SSH server on a Debian/Ubuntu operating system to access a remote computer or server. If you did not select the "SSH server" option from the predefined collections of software during the installation of the operating system

Software selection Debian 10

and the OpenSSH server does not work for you, do not worry, we will fix it now.

This instruction was executed on operating systems: Debian 10, Debian 9, Ubuntu 20.10, Ubuntu 20.04, Ubuntu 19.10.

Installing OpenSSH server

Before any software installation, it is recommended to update the list of repository packages by running the command in the terminal:

sudo apt-get update

Install the OpenSSH software to support the SSH protocol by running the command in the terminal:

sudo apt-get install openssh-server

but I prefer the short version, which immediately installs the client and server OpenSSH

sudo apt-get install ssh

SSH installation command

–°hecking SSH status

Let's check if SSH is enabled to start automatically when the system is booted by running the command in the terminal (expected result "enabled"):

sudo systemctl is-enabled ssh

Let's check if SSH is active at the moment by running the command in the terminal (expected result "active"):

sudo systemctl is-active ssh

We can also check the SSH status with additional information about the service by running the command in the terminal:

sudo systemctl status ssh

–°hecking SSH status

If the SSH server is not installed, an error will be displayed when checking the status:

Error checking SSH status

Testing SSH access

Now we can try to connect to the local SSH server. But first, let's create a temporary user named "newuser" by running the command in the terminal:

sudo adduser newuser

Add new user

Connect to a new user on the local SSH server by running the command in the terminal:

ssh newuser@localhost

When you first connect, you must authenticate the host by entering "yes":

Testing SSH access

Now we have full access to the user "newuser". Let's try to add a directory and check if it was created. To close an SSH connection, simply enter the command:

exit

Close SSH connection

Well, in the end we will remove the temporary user by executing the command in the terminal:

sudo deluser --remove-home newuser

In the same way, access to a remote computer or server via the SSH protocol is obtained, but instead of localhost, the IP address of another computer is indicated:

ssh username@192.168.0.100

Other articles