Secure Shell (SSH) is a powerful protocol that allows users to securely access and manage remote systems over an unsecured network. For system administrators and developers, using SSH is essential when working with Linux servers. Ubuntu 24.04 LTS, with its Long Term Support and regular updates, is often a preferred choice for servers. Installing and configuring SSH on Ubuntu 24.04 is a straightforward process that enhances remote system management and automation.
Installing OpenSSH Server
By default, Ubuntu systems may not have the SSH server package installed. To enable secure remote access, administrators must install the OpenSSH Server package. To do this, follow these steps:
- Open a terminal window on the system or remotely connect using another method (like a cloud console).
- Update the package list using the command:
sudo apt update
- Install the OpenSSH Server with:
sudo apt install openssh-server
The system will download and set up the SSH server and its necessary components. Once completed, the SSH service will start automatically.
Verifying SSH Service Status
After installation, it’s important to confirm that the SSH daemon (sshd
) is running correctly. To check the status, use this command:
sudo systemctl status ssh
If the service is active and running, the terminal will display output confirming that SSH is operational.
To enable the SSH service to start automatically with the system, use:
sudo systemctl enable ssh

Adjusting Firewall Rules
Ubuntu 24.04 uses ufw (Uncomplicated Firewall) to manage firewall rules. If ufw is active, allow SSH connections by running:
sudo ufw allow ssh
This command permits traffic on port 22 (default SSH port), enabling secure remote access. To verify the firewall status and confirm the rule was added, use:
sudo ufw status
Testing SSH Connectivity
Now, test the SSH functionality to ensure that it works properly. From another machine, connect to the Ubuntu server using:
ssh username@server_ip_address
Replace username
with your actual Ubuntu login name and server_ip_address
with the system’s IP address. If it’s the first time connecting, acknowledge the host key fingerprint prompt to continue.

Securing the SSH Server
To enhance security, several best practices can be followed:
- Change the SSH port: Modify the
/etc/ssh/sshd_config
file to use a different port, reducing the risk of automated attacks. - Disable root login: In the same config file, set
PermitRootLogin no
to prevent direct root access. - Use key-based authentication: Instead of passwords, generate SSH keys using
ssh-keygen
and add the public key to the server’s~/.ssh/authorized_keys
file.
After making changes to the configuration file, apply them with:
sudo systemctl restart ssh
Disabling SSH (If Required)
In some cases, you might want to disable SSH, either temporarily or permanently. Use the following commands as needed:
- To stop the SSH service:
sudo systemctl stop ssh
- To disable SSH from starting on boot:
sudo systemctl disable ssh
Conclusion
SSH installation and configuration on Ubuntu 24.04 LTS is a critical step toward establishing a secure and flexible server environment. With just a few commands, users can enable remote access, enforce security policies, and streamline system administration. Whether you’re running a personal server or managing a dozen instances in the cloud, SSH is a fundamental component of modern Linux-based infrastructure.
Frequently Asked Questions (FAQ)
- Q: Is SSH installed by default on Ubuntu 24.04 LTS?
A: No, the OpenSSH Server is not installed by default. You must install it manually usingsudo apt install openssh-server
. - Q: What port does SSH use?
A: By default, SSH operates on port 22. This can be changed in the/etc/ssh/sshd_config
file. - Q: How can I improve SSH security?
A: Use public key authentication, disable password-based login, prevent root access, and consider changing the default SSH port. - Q: How do I restart the SSH service?
A: Use the commandsudo systemctl restart ssh
to apply any configuration changes. - Q: Can I use SSH to tunnel other connections?
A: Yes, SSH supports tunneling and port forwarding, making it useful for secure VPN-like connections and encrypted communication.