Greenwebpage Community Blog Tutorials How to Enable SSH on Ubuntu 24.04
Tutorials

How to Enable SSH on Ubuntu 24.04

SSH is a protocol that makes an encrypted connection for remote access between a server and a client. It encrypts and manages all data transmitted during the remote session. Additionally, SSH provides a secure method for easily accessing your system from another computer.

Enable SSH on your Ubuntu 24.04 with this illustrated guide.

How to Enable SSH on Ubuntu 24.04?

The following are necessary steps for installing and enabling SSH:

How to Install and Start SSH on Ubuntu 24.04?

How to Set up SSH Service on Ubuntu 24.04?

How to Check the IP and Port of a Remote Machine

How to Connect/Test SSH Server on Ubuntu 24.04?

How to Remove SSH from Ubuntu 24.04?

Conclusion

How to Install and Start SSH on Ubuntu 24.04?

Install and start SSH services on your Ubuntu 24.04 using these commands.

Step 1: Update Packages

Improve your Ubuntu machine’s performance by refreshing and updating its packages list with the command:

sudo apt update

This command will inspect the installed packages of your Ubuntu 24.04 system and will update the system files if needed.

Step 2: Install SSH Package

First install the SSH server and client to enable the SSH service:

sudo apt install openssh-client openssh-server -y

The above output on your Ubuntu screen confirms that the SSH package is now installed successfully.

Step 3: Start the SSH Service

Through this command, you can start the SSH service on your Ubuntu 24.04:

sudo systemctl start ssh

When the SSH service starts you will be returned an empty output on your terminal.

Step 4: Enable SSH Service

let’s enable the SSH service at boot through the provided command:

sudo systemctl enable ssh

Similar to the above screen will be shown on your Ubuntu terminal.

How to Set up SSH Service on Ubuntu 24.04?

These steps can be utilized to set up SSH on your Ubuntu machine.

Step 1: Modify SSH Configuration

For the safe and smooth performance of SSH, you can make some necessary modifications in the SSH configuration file. SSH configuration file can be accessed:

sudo nano /etc/ssh/sshd_config

In the SSH configuration file, make the necessary changes, such as specify a secure and dedicated Port:

Once you have modified the SSH configuration file, save and close the file.

Step 2: Enable Firewall for SSH

The below command is essential to set up a firewall to control network traffic on your Ubuntu 24.04:

sudo ufw enable

The snapshot above, confirms that the Firewall on your machine is now active and enabled.

Step 3: Allow Port 2024 for Incoming Traffic

Allow the specified ports (e.g., port 2024) to ensure it is accessible through the firewall:

sudo ufw allow 2024

The above output confirms that the Firewall rules have been added to allow the port 2024 for the incoming traffic.

Step 4: Reload the Firewall

To apply the updated changes, reload your Firewall using this command:

sudo ufw reload

If no error occurs after executing the above command, it means that you have successfully enabled and started the Firewall on your Ubuntu 24.04 machine.

Step 5: Check SSH Status

Now, you can verify the existing SSH status on your Ubuntu system:

sudo systemctl status ssh

You will find that the SSH services are now enabled and active, allowing port 2024 for incoming traffic.

How to Check the IP and Port of a Remote Machine

To confirm the assigned port and IP address of a remote machine, follow these steps.

Step 1: Find the IP Address

To test the SSH server, you need the IP address of the remote machine (e.g., ubuntu24@Zahid). To check the IP address, operate the command on the remote machine:

hostname -I

The command will print a list of IP addresses associated with the network interfaces of your machine.

Step 2: Check SSH Status Remote Machine

Also, check if the remote machine is properly connected to the internet and ensure that SSH is running on your machine:

sudo systemctl status ssh

Ensure that the remote server is using the same port (e.g., 2024) for the SSH service.

How to Connect/Test SSH Server on Ubuntu 24.04?

Perform the below commands to test or connect the SSH server on your machine.

Step 1: Connect to the SSH Server

Once you have activated the SSH server and assigned a secure port, let’s test the connection by running this command:

ssh -p 2024 ubuntu24@192.168.249.213

The “-p” option specifies the port, followed by the “user@IP_address”.

Enter the password for the remote machine to connect via SSH.

Step 2: Check the Details of the Remote Machine

To display system information about the remote machine, use the command:

uname -a

exit

After verifying the system information or other tasks, you can exit the SSH connection with the “exit” command.

How to Remove SSH from Ubuntu 24.04?

You can remove the SSH packages from your Ubuntu 24.04 system with the following few commands.

Step 1: Stop SSH Service

The SSH service can be terminated and stopped using the below command:

sudo systemctl stop ssh.service ssh.socket

Confirm that the SSH socket on your machine is also stopped.

Step 2: Disable SSH Service

Operate the command to disable the SSH from starting on boot:

sudo systemctl disable ssh.service ssh.socket

The output message on the screen confirms the execution of the command.

Step 3: Remove SSH Package

After successfully stopping the SSH service, remove the SSH client and server packages with the following command:

sudo apt purge openssh-client openssh-server -y

This command will completely remove the SSH service, including the client and server packages.

Step 4: Verify SSH Removal

To confirm that SSH packages have been removed from your system, check the SSH version with the following command:

ssh -V

If the SSH packages are removed, the command will return a message indicating that no such file was found.

Conclusion

On Ubuntu 24.04, enabling SSH can be done in a few steps. First, confirm that the SSH packages are properly installed and active on your system. Then, run the commands “sudo systemctl start ssh” and “sudo systemctl enable ssh” to properly enable SSH on your Ubuntu 24.04 system.

Exit mobile version