UbuntuUbuntu Based

How To Install SSH Server on Ubuntu 24.04 LTS

Install SSH Server on Ubuntu 24.04

In this tutorial, we will show you how to install SSH Server on Ubuntu 24.04 LTS. Secure Shell (SSH) is a cryptographic network protocol that enables secure remote access to servers and other network devices. SSH provides a reliable and encrypted communication channel between two untrusted hosts over an insecure network. By using SSH, system administrators and users can securely log in, execute commands, and transfer files between computers. Installing an SSH server on your Ubuntu 24.04 system is a straightforward process that offers numerous benefits, such as enhanced security, remote management capabilities, and the ability to securely tunnel other network services.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the SSH Server on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.

Prerequisites

  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install SSH Server on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

To ensure a smooth and successful installation, it is crucial to update your Ubuntu system before installing any new packages. Updating the system helps to fetch the latest package lists from the repositories and upgrade any existing packages to their most recent versions. This step is essential to maintain system stability, security, and compatibility.

 To update your Ubuntu 24.04 system, open a terminal and execute the following commands:

sudo apt update

The sudo apt update command refreshes the package lists, while sudo apt upgrade upgrades the installed packages to their latest available versions. If the upgrade process includes a kernel update, you may need to reboot your system for the changes to take effect. You can do this by running:

Step 2. Installing SSH Server on Ubuntu 24.04.

With your system updated, you can now proceed to install the OpenSSH server package. OpenSSH is a widely used open-source implementation of the SSH protocol, and it provides the necessary components to set up an SSH server on your Ubuntu 24.04 machine.

To install the OpenSSH server, run the following command in your terminal:

sudo apt install openssh-server

The package manager will resolve any dependencies and prompt you to confirm the installation. Press ‘Y’ and then ‘Enter’ to proceed. Once the installation is complete, the SSH service will start automatically.

To verify that the OpenSSH server is installed and running, you can use the following command:

sudo systemctl status ssh

You can also manually start, stop, enable, or disable the SSH service using the following commands:

sudo systemctl start ssh
sudo systemctl stop ssh
sudo systemctl enable ssh
sudo systemctl disable ssh

Step 3. Configure SSH Server.

After installing the OpenSSH server, you may want to customize its configuration to suit your specific needs and security requirements. The main configuration file for the SSH server is located at /etc/ssh/sshd_config.

Before modifying the configuration file, it is a good practice to create a backup of the original file. This allows you to easily revert to the default settings if needed. To create a backup, use the following command:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig

Now, open the configuration file in a text editor with sudo privileges:

sudo nano /etc/ssh/sshd_config

Here are some common settings you may want to modify:

  • Port: By default, SSH listens on port 22. You can change this to a different port number to enhance security. For example, to use port 2222, uncomment the Port line and change the value to 2222.
  • PermitRootLogin: This setting determines whether root login is allowed over SSH. It is generally recommended to disable root login and use sudo instead. To disable root login, change the value to no.
  • PubkeyAuthentication: This setting controls whether public key authentication is allowed. If you plan to use SSH keys for authentication, ensure this option is set to yes.
  • PasswordAuthentication: This setting determines whether password-based authentication is allowed. If you prefer to use SSH keys exclusively, you can disable password authentication by setting this option to no.

After making any changes to the configuration file, save and close the file. For the changes to take effect, you need to restart the SSH service:

sudo systemctl restart ssh

Before restarting the service, it is a good idea to test the configuration file for any syntax errors:

sudo sshd -t

Step 4. Adjust Firewall Settings.

By default, Ubuntu 24.04 comes with a firewall configuration tool called Uncomplicated Firewall (UFW). To ensure that your SSH server is accessible from remote machines, you need to configure the firewall to allow incoming SSH connections.

First, check the status of the firewall:

sudo ufw status

If the firewall is inactive, you can enable it with the following command:

sudo ufw enable

To allow SSH traffic through the firewall, use the following command:

sudo ufw allow ssh

If you have configured SSH to use a custom port, you need to specify the port number instead of ssh. For example, if you are using port 2222, the command would be:

sudo ufw allow 2222/tcp

After making changes to the firewall rules, verify the updated status:

sudo ufw status

Step 5. Connect to SSH Server.

With the SSH server installed, configured, and accessible through the firewall, you can now connect to it from remote machines.

  • Connecting from Linux or macOS

To connect to your SSH server from a Linux or macOS machine, open a terminal and use the following command:

ssh user@server-ip

Replace user with the username you want to log in as, and server-ip with the IP address or domain name of your SSH server.

If you have configured SSH to use a custom port, you need to specify the port number using the -p flag:

ssh -p port user@server-ip
  • Connecting from Windows

To connect to your SSH server from a Windows machine, you can use an SSH client like PuTTY. Download and install PuTTY, then launch the application. Enter the IP address or domain name of your SSH server in the “Host Name” field, and specify the port number if you have changed it from the default. Click “Open” to initiate the connection.

Congratulations! You have successfully installed the SSH Server. Thanks for using this tutorial for installing the SSH Server on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the SSH website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button