In Ubuntu, enable SSH to securely manage and access your servers and network devices remotely. SSH is short for Secure Shell. SSH is important for System Administrators, network administrators, and developers to manage remote systems securely and efficiently.
What is SSH in Linux?
SSH or Secure Shell is a cryptographic network protocol. SSH protocol provides a secure channel over an insecure network. The primary advantage of SSH is that SSH encrypts data, which means all commands, passwords, and other sensitive information cannot be eavesdropped on and are always protected.
In Ubuntu Enable SSH Advantages
At Unixmen, we always explain why a feature is important before we explain how to use it. This ensures our readers utilize the feature to its maximum capacity. Enabling SSH on an Ubuntu (or any Linux) system is important for secure remote access and management. SSH provides encrypted communication between the host and servers. This ensures that all sensitive data like passwords, commands, and confidential information are protected from unauthorized eyes. SSH allows system and network administrators to securely:
- Manage servers from remote locations
- Perform critical updates
- Fix issues
- Use scripts to automate tasks
In addition to these benefits, SSH also supports file transfers, port forwarding, and tunneling. These added benefits make SSH a flexible tool to maintain and control Linux systems efficiently, with the primary emphasis still being on security.
Prerequisites in Ubuntu to Enable SSH
To enable SSH on your Ubuntu (or any other Linux device), ensure you have:
- An internet connection
- Sudo (administrator) access to the Ubuntu device
- An Ubuntu device running on Ubuntu 20.04 LTS or higher versions.
Steps to Enable SSH in Ubuntu
- Install OpenSSH Server
- Configure SSH
- Enable SSH
- Connect to Ubuntu device
- Secure SSH
- Use a Firewall
Install OpenSSH Server on Ubuntu Device
To install OpenSSH server on your Ubuntu device, open a terminal window and update your package lists by running the command:
Once the package lists are updated, install the OpenSSH server package by executing the command:
As a precautionary measure, confirm if the installation was successful by running the command:
Everything is well and good until now if the status should show as active and running. If that is not the case, install the package again.
How to Configure SSH in Ubuntu
Once the installation is complete, configure SSH for better customization and security. To configure SSH, open the SSH configuration file by opening and editing the sshd_config file.
Save the changes to the configuration file and exit the editor.
You can then configure SSH according to your requirements. Some common configurations include:
- Allowing only specific users: AllowUsers Unixmen1 Unixmen2)
- Disabling root login: PermitRootLogin no
- Change the default port (Port 443)
Save the changes to the configuration file and exit the editor.
Ubuntu: Enable SSH
Once installed, by default the SSH service will start automatically after installation. If for some reason the SSH service has not started, in Ubuntu enable SSH by executing the command:
You can either check SSH service status or set it to start everytime on boot by executing the command:
Connect Ubuntu Device from Remote System
To connect to an Ubuntu device from a remote system, open the terminal on the remote system and execute this command to initiate connection:
Enter your password when prompted.
Secure SSH Connection
This step is completely optional. To enhance security, prefer SSH keys instead of passwords. To use keys, generate an SSH key pair on your local device. Copy the public key to your Ubuntu server. Disable password authentication in the SSH configuration file (we learned about this earlier) and implement two-factor authentication.
Setup Firewall
There are two steps involved to use the firewall in Ubuntu to enable SSH. Allow SSH through firewall by executing the command:
Enable the firewall by executing the command:
Wrapping Up
In Ubuntu, enable SSH to experience ease and security in remote management. As you can see from our easy-to-follow guide, it is fairly straightforward in Ubuntu to enable SSH. With SSH, you can securely access your Ubuntu servers from anywhere. This streamlines your workflow and enhances your system administration capabilities. SSH offers both convenience and security. Enable SSH on your Ubuntu machines and let us know how you plan to use it.
Related Link
Ubuntu’s documentation on OpenSSH server