Installing OpenSSH server on Ubuntu
First of all, check if SSH is already installed.
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.
Changing default port for the OpenSSH server
In /etc/ssh/sshd_config file, search for the following line:
Change the port to a desired one. For example:
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>
ssh -p <port number> <user account>@<server hostname>
For example, you can run a command like this:
ssh -p 4422 firstname.lastname@example.org