OpenSSH or open secure shell protocol provides secure communication channels while communicating over potentially insecure networks. OpenSSH represents the practical implementation of the SSH protocol, relying on both the client and server components.
The primary use for OpenSSH on Linux-based operating systems is to access the command line interface remotely of the client machine. By doing this, you can execute various commands and transfer data as well. To use this protocol on Ubuntu 24.04 not only do you have to install it first but also have to enable it and this guide is about enabling the OpenSSH service.
Outline:
- How To Enable OpenSSH on Ubuntu 24.04
- Accessing Ubuntu 24.04 Through OpenSSH
- Accessing a System From Ubuntu 24.04 via OpenSSH
- Setting up a Custom Port for SSH on Ubuntu 24.04
- Conclusion
How To Enable OpenSSH on Ubuntu 24.04
The OpenSSH still stands out over other communication mediums as it comes with strong encryption algorithms which are difficult to crack. It uses public-key cryptography for authentication including support for a wide range of key types, thus providing better security and performance. On Ubuntu 24.04 it doesn’t come preinstalled so you have to install it via apt:
Installing the OpenSSH server automatically installs the client as well but if you need your system for only accessing other systems then you can install only the client and for that execute:
After the installation is complete now enable the SSH service on Ubuntu:
After enabling the service verify its status through the systemctl utility:
If by any means the service is still not active then try starting it, usually the ssh service automatically starts upon enabling it:
To ensure the proper functioning of SSH service it has to be allowed via a firewall as it might block the communications except port 22:
Once the rules are added verify them by checking the status of the firewall and afterward reload the firewall to apply the changes:
Accessing Ubuntu 24.04 Through OpenSSH
The OpenSSH is now enabled and you can access your Ubuntu 24.04 on any other system. For that first find out the IP address of your system:
Now just use the SSH command sling with the username and the IP address of your system on the host system:
Here, I have accessed Ubuntu 24.04 on Debian 12 through SSH protocol. On the first login, the system will ask for confirmation to proceed, enter yes:
Now if you want to exit the remote device then execute:
Accessing a System From Ubuntu 24.04 via OpenSSH
In the below image, I have accessed Debian 12 from Ubuntu 24.04 using the same command used for accessing Ubuntu 24.04 from Debian 12:
Setting up a Custom Port for SSH on Ubuntu 24.04
By default, the SSH service uses port 22 for communication which makes the network vulnerable to cyberattacks and sometimes it can cause port conflicts in case you are using NAT configuration for multiple servers. To change the port for SSH open the SSHd_config file in any editor:
Here you can set the port number from 1024 to 65535, the reason behind keeping the number in this range is to strike a balance between avoiding reserved ports and minimizing the risk of collisions. Here, I have selected port number 1046:
Now restart the SSH service to apply the port changes:
To enable SSH communication over the new port, you have to allow it through the firewall and for that execute:
Now verify the rules added for the new port and then reload the firewall:
sudo ufw reload
Now use the set port to access the server from Ubuntu by executing:
Note: The SSH is a client-side tool that is used for system administration file transfers and communication across untrusted networks. Whereas sshd is the server-side daemon that listens to incoming connections via SSH protocol. It handles user authentication, encryption terminal connections, and tunneling.
Conclusion
To enable OpenSSH on Ubuntu 24.04 you first need to install it via its default package installer and then enable it through systemctl command. By default, it uses port 22 which can be changed to a custom port number ranging from 1024 to 65535. Further, to access any system from Ubuntu 24.04 use the server IP address, its username along with the ssh command.
I’m Aaliyan javaid, an electrical engineer and a passionate tech enthusiast. I have been working with embedded systems, programming, and Linux operating systems for over 2 years. I love to explore new technologies and share my knowledge and experience with others.