Ubuntu

How to Install and Configure Linux SSH


“Accessing Linux machines remotely is not a new phenomenon. This necessity dates back several decades ago, and it is currently impossible to imagine a world with no protocols for controlling remote machines.

Notably, SSH is now the default system for accessing Linux servers in the modern world. The Secure Shell framework is powerful and efficient. It helps to establish connection and communication between two computing devices or routers remotely.

And since it is a secure protocol, it encrypts all connections to ensure that your data or information does not land in the wrong hands. Thus, attackers are unable to eavesdrop or hijack details in the connection. Besides, it offers an array of authentication modes and configuration options.

This article focuses on configuring Linux SSH on Linux. And being a server-client protocol, we will discuss the configuration process on the server and client machines. But before that, let us highlight the prerequisites of the setup process.”

Prerequisites for Installing SSH on Ubuntu

Setting up the SSH protocol on Linux is not a complicated process. However, you need to ensure that you meet the following conditions;

  • Only users with sudo privileges on server machines can install and configure SSH.
  • You must have at least one more different system on your network. This system could be another LAN computer, a virtual computing device hosted in your device, or a remote server connected to your system via the internet.
  • You need a stable internet connection since you will need to download the required packages for installation.

Setting Up Linux SSH on Ubuntu Linux

sshd or OpenSSH Daemon or server is an open source (free) ssh server which functions as the utility program for the ssh client. It is the replacement for rsh and rlogin, which are relatively insecure.

Notably, both minimal Ubuntu and Ubuntu desktop do not come with sshd set up and running. However, you can quickly and conveniently install and set up Linux SSH on Ubuntu by following these steps;

Step 1: Install SSH Server
The configuration process begins with installing SSH on your server, and you can do that by following these steps;

a. Open Ubuntu Desktop
Open the terminal window on your Ubuntu Desktop.

b. Update Your System
Update the Ubuntu System to ensure your machine has the latest version. It is vital to do this before installing new software or packages in your system. The below command should help with the update process;

c. Install SSH
Once your system is up to date, you can install OpenSSH into your server machine. You can use the command below;

Step 2: Verify That the System is Running
Once installed, verify the status of your ssh service using the below command;

The above command should give you a result similar to the one in the image below. Note that the “Active (running)” is highlighted to indicate that SSH installation is successful and the protocol is already running in your systems.

Step 3: Enable and Start SSH
If SSH does not return an active result, enable the SSH protocol in your systems by typing this utility. You only do this in case your SSH service is not running. Otherwise, you can pass this step if it is running.

Step 4: Allow SSH Through the Firewall
Ubuntu comes with the Uncomplicated Firewall (UFW), which manages network rules by default. An active UFW will potentially prevent the connection of SSH to your server. You can change UFW settings to allow connection to the SSH server. You should also use this command t open port 22.

These commands will help you configure UFW to allow connection;

Step 5: Test Your SSH System
Log in to your Linux computer and test SSH using the following command;

The result of the above command should be a display of the various components of your SSH server protocol.

Setting Up SSH Client on Linux

You can proceed to configure the SSH client. Notably, this allows connection to the remote server from your local machine. The procedure for setting up an SSH client is as follows;

Step 1: Install SSH Client
Your local machine should have the latest SSH version installed. But in cases where no SSH client is already installed, you can use the below command to install the client on Ubuntu;

Step 2: Connect to the Remote System
You can establish a connection to your remote system from the local computer. To achieve this, you should know the IP address of your local command and use this command;

You can also query the computer for your IP address if you do not know it. This is possible by typing (ip a) on your server’s terminal. The display will have all the necessary details, including your IP address.

Conclusion

The above step-by-step guide should help you configure SSH on your system. Once you install and set up SSH on both your server and client machines, you should be able to access your server remotely once you establish a connection.

Sources

About the author

Kennedy Brian

Brian is a computer scientist with a bias for software development, programming, and technical content development. He has been in the profession since 2015. He reads novels, jogs, or plays table tennis whenever not on gadgets. He is an expert in Python, SQL, Java, and data and network security.