OpenSSH is a set of tools that lets you have secure, encrypted communication over a network using SSH. It includes features for secure remote login, file transfer, and tunneling of applications. OpenSSH is commonly used on Linux systems for secure remote access and file transfers. It is highly reliable and trusted by many users around the world for its strong security measures.
This tutorial will help you to install OpenSSH server on Ubuntu 24.04 systems.
Steps to Setup OpenSSH on Ubuntu 24.04
Follow the step-by-step instructions to install and configure OpenSSH server on Ubuntu 24.04 LTS Linux server.
Step 1: Update Your System
Before installing or updating the OpenSSH server, make sure your system packages are up-to-date. Run these commands:
sudo apt update
sudo apt upgrade
Step 2: Installing OpenSSH Server
OpenSSH packages are included under default Debian repositories, which you can install directly. To install the OpenSSH server on your Ubuntu system, use this command:
sudo apt install openssh-server
This will download and install the OpenSSH server package and its dependencies.
Once the installation finished, check if the OpenSSH server is running with this command:
sudo systemctl status ssh
You should see output indicating that the OpenSSH server is active and running:
Step 3: Configure the OpenSSH Server (Optional)
To configure the OpenSSH server, edit the sshd_config file located in the /etc/ssh/ directory. Open the file with this command:
sudo nano /etc/ssh/sshd_config
Here are some common settings you might want to change:
- Port: The default port is 22. You can change it to a different port number for extra security.
- PermitRootLogin: For security, it’s best to disable root login by setting this to no.
- PasswordAuthentication: If you prefer public key authentication, set this to no.
- AllowUsers: To restrict SSH access to specific users, add their usernames here, separated by spaces, e.g., AllowUsers user1 user2.
After making changes, save and close the file. Apply the new settings by restarting the OpenSSH server with this command:
sudo systemctl restart ssh
Step 4: Adjust Firewall Rules
If you have a firewall enabled, you need to allow SSH connections. For Ubuntu systems using UFW, run this command:
sudo ufw allow ssh
If you changed the SSH port in Step 4, use the new port number, e.g., sudo ufw allow 2222/tcp
.
Conclusion
This guide shows you how to install or update the OpenSSH server on Ubuntu 24.04. By following these steps, you have successfully installed, configured, and tested the OpenSSH server. With OpenSSH, you can securely access and manage your Linux systems remotely, ensuring safe and encrypted communication over your network.