Categories
SSH

How to install and use OpenSSH server on Ubuntu 20.04

Installing OpenSSH server on Ubuntu

First of all, check if SSH is already installed.

ssh -V

Make sure that your database for packages is up to date.

sudo apt update

Install the OpenSSH by executing the following command:

sudo apt install openssh-server

You can check that the OpenSSH server is actually running.

sudo systemctl status sshd

Enabling OpenSSH server on system boot

If you want the OpenSSH server to start on system boot, you should enable the ssh service.

sudo systemctl enable ssh

Configuring OpenSSH server on Ubuntu

The configuration file for the OpenSSH server is /etc/ssh/sshd_config.

vi /etc/ssh/sshd_config

Changing default port for the OpenSSH server

In /etc/ssh/sshd_config file, search for the following line:

#Port 22

Change the port to a desired one. For example:

Port 4422

Restarting OpenSSH server to apply the new settings

Apply the changes in /etc/ssh/sshd_config file to OpenSSH server by executing the following command:

sudo systemctl restart sshd

Stopping OpenSSH server

To stop the OpenSSH server, execute the following command:

sudo systemctl stop sshd

How to connect to OpenSSH server

The command syntax:

ssh -p <port number> <user account>@<server IP address>

or

ssh -p <port number> <user account>@<server hostname>

For example, you can run a command like this:

ssh -p 4422 foo@192.168.1.123

6 replies on “How to install and use OpenSSH server on Ubuntu 20.04”

Leave a Reply

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