Secure Shell (SSH) is a cryptographic network protocol utilized for secure data communication, remote command-line login, remote command execution, and other secure network services between two networked computers. It is a secure alternative to the non-protected login protocols (such as Telnet) and insecure file transfer methods (like FTP).
In this tutorial, we’ll guide you through the process of enabling SSH on a Linux server. Before starting, make sure you have root or sudo access to your machine.
Step 1: Installing OpenSSH server
OpenSSH is the most popular SSH server on Linux. In most cases, it’s already pre-installed on your Linux system. If not, you can easily install it using your system’s package manager.
For Debian-based distributions like Ubuntu, use the apt package manager:
sudo apt-get update sudo apt-get install openssh-server
For Red Hat-based distributions like CentOS, use the yum package manager:
sudo yum install openssh-server
Step 2: Starting the SSH service
Once you’ve installed OpenSSH, you should start the service. For systems using systemd (like Ubuntu 16.04 and higher), use the following command:
sudo systemctl start ssh
Also, to ensure SSH starts automatically at boot, run the following command:
sudo systemctl enable ssh
Step 3: Testing SSH access
To confirm that SSH is running on your machine, you can run the following command:
ssh localhost
You should see a message like “Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 5.0.0-1031-azure x86_64)”, which means SSH is working correctly.
Step 4: Configuring SSH (Optional)
The default SSH configuration on Ubuntu is pretty secure. However, you can modify the configuration file located at /etc/ssh/sshd_config to tweak the settings. Always make sure to restart the SSH service after making changes to this file:
sudo systemctl restart ssh
That’s it! You’ve successfully enabled SSH on your Linux server. You should now be able to securely connect to your server using a SSH client.