How to Install OpenSSH Server on Ubuntu 24.04

In this article, we will show you how install OpenSSH server on Ubuntu 24.04.

The Secure Shell (SSH) protocol is vital in remote server control and providing safe file transfers over a network. Encryption through cryptography forms a central part of SSH connections. The OpenSSH function, a standard SSH implementation, ensures authentication and encryption to stop network surveillance and connection hijacking.

This article is worth your time as it explains how an Ubuntu user can install the OpenSSH server on Ubuntu 24.04.

Prerequisites

While installing the OpenSSH server, ensure you have the following;

  • A system running on Ubuntu 24.04
  • An internet connection
  • Root access or sudo privileges

How to Install OpenSSH Server on Ubuntu 24.04

1) Updating and Upgrading System Packages

Users must update system packages before installing software because this enhances security and compatibility.

To update your installed packages, run the following command on your terminal.

$ sudo apt update

apt update packages

The update begins once you provide your password.

After updating the packages, upgrade them to the latest versions using the following command;

$ sudo apt upgrade

sudo apt upgrade command

System update begins after the user provides a password.

2) Install OpenSSH Server

After updating your system, install the OpenSSH server on Ubuntu 24.04 using the following command.

$ sudo apt install openssh-server

install openssh server on Ubuntu 24.04

Enter your password to execute the command on your system. Type “Y” then press Enter when asked if you want to continue with the installation process.

OpenSSH Server Ubuntu 24.04

The OpenSSH server and its dependencies are installed on your Ubuntu system upon completion.

3) Verifying the OpenSSH Server Installation

After installing OpenSSH Server, type the following command on your terminal to ensure that the server is running.

$ sudo systemctl status ssh

If the server is installed correctly and running, you should see the server is active, similar to the image below:

Verify SSH Service Status

If the ssh service is not running, start it manually using the following command.

$ sudo systemctl start ssh

Start SSH Service On Ubuntu 24.04

To ensure that OpenSSH starts automatically when a system boots, use the following command.

$ sudo systemctl start ssh

4) Configuring the OpenSSH Server

Configure the recently installed OpenSSH Server using the following command;

$ sudo nano /etc/ssh/sshd_config

OpenSSH Server Configuration file

After opening the file, remove the # at the beginning of any line you want to enable. You can now modify the settings as needed.

Edit OpenSSH Server Configuration File

For instance;

  • Change the SSH port for added security. The image shows that the port has been changed from the default 22 to 225.
  • MaxAuthTries 4 – This sets the maximum number of authentication failures to 4.
  • PermitRootLogin no – This disables root login for security purposes.

Once you are done with the modifications, save your changes by pressing CTRL + S and exit by pressing CTRL + X.

Then, restart the OpenSSH service using the following command:

$ sudo systemctl daemon-reload
$ sudo systemctl restart ssh

You can confirm your port changes using the following command;

Check OpenSSH Server Port Ubuntu

Therefore, the port change was successful, as the terminal indicated that the port number was 225.

5) Allow the New SSH Port in UFW

If UFW (Uncomplicated Firewall) is enabled, allow the new SSH port (225) and remove the old one (22):

$ sudo ufw allow 225/tcp
$ sudo ufw delete allow 22/tcp
$ sudo ufw reload

Conclusion

OpenSSH helps in remote system administration and transfer of files over a network without compromising security. Using the above step-by-step explanation on how to install OpenSSH Server on Ubuntu 24.04, a Linux user can easily install the server and ensure a reliable and safe remote connection.

Also Read: How to Install Ubuntu 24.04 on WSL2

Leave a Comment

one × two =