Installing Open-ssh server Ubuntu


SSH or Secure Shell is a protocol for secure access from one computer to another over a network. The SSH protocol has a lot of possibilities. You can create secure connections between computers, open a command prompt on a remote computer, run graphics programs, transfer files, and set up private networks.

The OpenSSH software suite is responsible for supporting the SSH protocol on Linux. This is an open implementation of this protocol that provides all the necessary features. The OpenSSH package includes utilities for establishing a connection, transferring files, and the ssh server itself.

Installing SSH on Ubuntu will be very simple, the program is considered standard and is used almost everywhere. Although by default it is not in the distribution, but it is in the official repositories.
Therefore, to install, open the terminal using the keyboard shortcut Ctrl + Alt + T and run the command:

$ sudo apt install openssh-server

Several packages will be downloaded, and when the Ubuntu ssh server installation is complete, the program will be ready to go. If you want the service to start automatically, you need to add it to startup. So to enable SSH on Ubuntu 20.04 run:

$ sudo systemctl enable sshd

As for the ssh client, it is already installed on the system by default. Now you can try to connect to your local ssh server by simply typing:

$ ssh localhost

In exactly the same way, you can ssh ubuntu access to any other computer on the network. To do this, it is enough to specify instead of localhost its ip address and username in the following format:

$ ssh username@ip_address


With the default settings, the SSH server is not very secure, so before the program is ready for full use, it needs to be configured a bit. All SSH server settings are stored in the sshd_config configuration file, which is located in the /etc/ssh folder.

Before making changes to this configuration file, it is recommended to make a backup copy of it, for this you can use the following command:

$ sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.factory-defaults

Next, you can move on to setting up the configuration file:

$ sudo vi /etc/ssh/sshd_config

The first step is to change the port on which ssh is running so that a possible attacker does not know if you have this service enabled. Find the Port line in the configuration file and replace its value with any number, for example, Port 2222:

By default, superuser login is enabled, it is recommended to disable this feature. To do this, find the line PermitRootLogin and replace its value with no:

To enable key authentication instead of password, look for the PubkeyAuthentication line and make sure its value is yes.

After all the settings are completed, save the changes by pressing :w and restart the SSH service:

$ sudo systemctl restart ssh

If you changed the port, then when connecting in the client, you also need to specify a new port, since 22 will be used by default, for example:

$ ssh -p 2222 localhost

In addition, if a firewall is installed and configured on the computer, then it also needs to allow access to the new ssh port, to do this, run:

$ sudo ufw allow 2222

Even if the ssh service is on the default port, you also need to open it in the firewall if you are going to connect to the computer via the Internet:

$ sudo ufw allow 22

The Ubuntu 20.04 ssh setup is complete.

Perfect cloud hosting 12$