Installing SSH on Ubuntu 24.04 LTS Running Linux

Heyan Maurya
8 Min Read

Unlock the remote access by installing SSH on Ubuntu 24.04 or any other Linux system. Because Secure Shell (SSH) is one of the safest and most secure ways to communicate with remote servers over unsecured channels. It offers not only strong authentication methods to log in but also encrypts our data while communicating with a remote server or desktop. Like previous generation Ubuntu systems, the setup of SSH client and Server is pretty easy on Ubuntu 24.04 as well because all the required packages are available to install using the default system repositories.

What do we learn in this article, and what is the requirement to follow the tutorial?

So, if you are looking for a quick way to install the Open-source SSH server on Ubuntu 24.04 along with its client, then this article is for you. Apart from that, here we will also discuss the commands to enable SSH, check the SSH server Status, allow port 22 in the UFW firewall, and restart the SSH server on Ubuntu 24.04 if required. For following the tutorial, the users don’t require anything special, just Ubuntu Linux with an active internet connection and sudo user rights to install the packages.

Installing SSH server & client on Ubuntu 24.04

Open your command terminal on Ubuntu 24.04 if you are not there already. After that, execute the system update command using APT, which will install the latest security updates and refresh the package repositories index cache.

sudo apt update && sudo apt upgrade

After that, run the APT install command to download the SSH client package and set it up on Ubuntu 24.04:

sudo apt install ssh

(optional) Installing the OpenSSH Server package

The above package will only install the SSH Client on your Ubuntu Linux; however, if you also want to set up an SSh server so that any remote system can access your Ubuntu Linux, then a Server package is also required. In short, we need the OpenSSH (Open Secure Shell) package, which is a suite of tools that implement the SSH protocol. It includes both client and server components, enabling secure communication between systems.

For that, we can execute the given command:

sudo apt install openssh-server

 

Enable and Start SSH on Ubuntu 24.04

After completing the installation process, it is important to start and enable the SSh service so that it can run automatically with system boot on Ubuntu. So, execute the given command:

sudo systemctl enable --now ssh

To confirm the SSH service is active, check its status:

sudo systemctl status ssh
SSh service status Ubuntu 24.04

Allowing SSH Through the Firewall

On most Linux systems, including Ubuntu 24.04, SSH port 22 traffic, by default, is configured to go through the system firewall. However, to confirm it so that we don’t get any problems while remotely accessing any system, use the given command and set UFW (Uncomplicated Firewall) to allow SSH traffic:

sudo ufw allow ssh

Check the firewall status to confirm the rule. This step ensures SSH connections are not blocked.

sudo ufw status

 

Testing SSH Connection

The standard SSH command Syntax is given below to test your SSH setup and establish a connection from your local or remote machine. Replace username with your actual user and your_server_ip with the server’s IP address. If you encounter issues, check the SSH logs for troubleshooting.

ssh username@your_server_ip

 

Setup and Configuring SSH Server (optional)

Besides just accessing the remote server, those who want other users to access their system should also configure their SSH server to enhance security. To do so, we can customize SSH settings in its configuration file. Open it using a text editor:

sudo nano /etc/ssh/sshd_config

Key configurations to consider:

Save and exit the file by pressing Ctrl+X, Y, and hit the Enter key. Apart from these settings, the users can also Install Fail2Ban to protect the system against brute-force attacks: Install, Configure, & Use Fail2ban on Ubuntu 24.04 or 22.04 LTS Server.

Restart ssh on ubuntu 24.04

To apply any changes made in the SSH configuration file, restart its service, and it can be done easily using the systemctl command as shown below:

sudo systemctl restart ssh

 

Update Openssh

As we have seen, the packages SSH and OpenSSH are both available in the default system repository of Ubuntu; therefore, whenever you run the system update command, it will also update your SSH server as well, if the latest version is available.

sudo apt update && sudo apt upgrade

Set Up SSH Key Authentication (optional)

SSH keys are more secure than passwords. Here’s how to set them up:

Generate SSH Keys: On your local machine, run. After that, Save the keys in the default location (~/.ssh/id_rsa).

ssh-keygen -t rsa -b 4096

Copy the Public Key to the Server: Use ssh-copy-id to transfer the public key:

ssh-copy-id username@remote_server_ip

Test the Connection: Log in to the server without a password:

ssh username@remote_server_ip

 

Uninstallation

Maybe later due to any problem, or you won’t require SSH on Ubuntu 24.04 Linux; in that scenario, if there is a need to remove I,t then execute the APT uninstall command with the package name as shown below:

For SSH client

sudo apt remove ssh

To remove the OpenSSH server

sudo apt remove openssh-server

 

Conclusion

Following our guide, even a beginner can easily install and configure the SSH on Ubuntu 24.04. It will help you to access the remote Linux machine securely and easily. However, let us know if you face any issues while implementing this secure protocol. The comment section is all yours…

 

Leave a Comment

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.