How to enable SSH in Ubuntu

SSH is a network protocol that is used to establish a secure connection between a client and a server.

SSH is an abbreviation for Secure Shell or sometimes its called Secure Socket Shell which is a network protocol that is used to establish a secure connection between client and server. It can allow users especially system administrators to access computers remotely through a secure channel on the top of an unsecured network.

The tool supplies users with powerful encryption and authentication methods to communicate data between computers that are connecting over an unsecured network.

SSH is commonly used by system administrators for connecting to remote machines, execute commands/scripts, handle the administrative tasks, securely transfer files from one machine to another and overall manage systems and applications remotely.

Also, you can use it function as or act as a proxy server and redirect your browsing traffic to an encrypted SSH tunnel. This will prevent users on public networks from seeing your browsing history.

In this article, we will help you installing SSH on Ubuntu and show you how to use it to connect remotely to other computers.

Enable SSH in Ubuntu

By default, the tool is not installed in Ubuntu but you can easily install it from the primary Ubuntu repositories.

Step 1. First, open Terminal and ensure your system is updated using the following command.

sudo apt update

Step 2. Enter the following command.

sudo apt install openssh-server

You will be asked to enter the sudo password. After entering the password, press Y to continue downloading and installing the SSH package.

Step 3. Check the SSH service status using the following command.

sudo systemctl status ssh

Usually, when the installation completes successfully you will find the SSH service will be started automatically. The output of the previous command will be something like that:

For now, we have installed SSH and its service is up and running on your machine. You can connect to it from any other remote machine that has SSH client installed. For Windows machines, you can use Putty. By default, the client is installed on Linux and macOS machines.

Connect to SSH via LAN

Now you can connect to your Ubuntu machine through LAN by following the below steps.

Step 1. First, you need to know your Ubuntu machine IP.

ip a

The output of the previous command will be something like that:

As you can see the IP is 10.0.2.15.

Step 2. From the remote machine use the following command to connect to your machine.

ssh username@ip-address

Where theusername is the username and theip-address is the IP of your machine.

So in our example, it will be :

ssh hendadel@10.0.2.15

For the first time when you are trying to connect to SSH, you will get a warning message like below:

Simply you can enter “yes” to continue, you will be asked to enter your password.

Once you have entered the password you will find a welcome screen like below:

And voila you are now logged in to your Ubuntu machine!

Step 3. To close the the session you can use the following command:

exit

Connect to SSH via the Internet

Before connecting to your machine via the internet, you will need to know the machine’s public IP. You can use the following URL “https://ifconfig.co/ip” to get your machine public IP which is the machine you are trying to connect to it through SSH.

Next, you need to configure your router to accept requests on port 22. Be cautious while setting this option as you may set your machine to a high-security risk. So, it’s highly recommended not to use the default port 22. Instead, you can make a simple turn around by configuring your router to accept SSH requests on a non-default port and to send or forward those requests to port 22 on the machine that has the service enabled. You should check your router’s documentation to enable port forwarding as each router has his own style for implementation.

Finally, you can use the below command to connect to your machine:

ssh username@public-ip-address

Whereusername is the username andpublic-ip-address is the IP of the machine you need to SSH it.

Disable SSH Service

In case you need to stop the SSH service on your Ubuntu machine you can use the following command.

sudo systemctl stop ssh

Alternatively to start the service again.

sudo systemctl start ssh

Or if you need to disable the service from starting during system boot you can use the next command.

sudo systemctl disable ssh

Also to enable it again use the next command.

sudo systemctl enable ssh

Finally, I hope you will find this tutorial helpful to you and for any further questions leave a comment below.

Hend Adel
Hi! I'm Hend Adel, a freelancer technical geek with successful experience in Database, Linux and many other IT fields. I help to build solutions to suit business needs and creating streamlined processes. I love Linux and I'm here to share my skills via FOSS Linux! Thanks for reading my article.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

STAY CONNECTED

23,555FansLike
365FollowersFollow
16SubscribersSubscribe

LATEST ARTICLES

The 10 Best Linux Server Distros For Home And Businesses

By the year 2020, it is estimated that there are close to 600 Linux distributions in the market. It includes both servers and Desktop versions; therefore, if you are looking for lightweight Linux distribution for your old PC or a reliable desktop version for employees in your organization, you may be overwhelmed with the number of choices for finding one for your use.

How to list the installed Packages on Ubuntu

It is only natural to start installing more and more software on your Ubuntu PC once you start using it. Similarly, it is also natural to lose track of the different packages that you have installed on your system. Eventually, you may be overwhelmed with the number of packages in your system and with the ones you hardly used.

How to configure the Ubuntu Firewall (UFW)

A properly configured firewall is a crucial part of establishing preliminary system security. Keeping this in mind, here we will go over how to configure the firewall on your Ubuntu PC.

How to install and use Zoom on Ubuntu

If you work from home or hold meetings with other people remotely, then you have probably heard of Zoom. It is one of the popular video conferencing software app available today.

How to Restart Networking on Ubuntu

Sometimes resetting your Ubuntu network is required to apply some network configurations like changing your IP from Automatic DHCP to static one. Restarting the network is not a big deal, but should be done carefully.

How to install Chrome and Chromium Browser on Pop!_OS

By default, Pop!_OS comes with Mozilla Firefox Browser installed to help you browse the internet. It is a reliable web browser covering almost all the features and functionalities you need. However, working with Firefox is noticeably different compared to Google Chrome, especially from the speed point of view. Google Chrome is a tad quicker than Firefox.

MUST READ

Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.
Elementary OS 5.1 Hera has received a point release with a handful of new features and bug fixes, and we will be reviewing the significant changes in this article. For those new to elementary OS, this Ubuntu-based Linux distribution uses their inhouse built Pantheon desktop environment and AppCenter.

6 Best Linux Distros for Programmers and Developers

Linux distros have long been a favorite among programmers since the rise in popularity of the OS in the nineties. Programmers are technical by nature, and Linux distros appeal to that technical nature. Let's discuss why Linux is a great desktop OS for programmers and developers, and find out best distros suitable for them.

6 best task managers for Linux

One of the essential tools in any Linux distribution is a Task Manager. It is a system monitor application that gives you a report of all programs running on your computer and the status of your RAM and CPU usage.

6 Essential Command-Line Utilities Every Linux User Should Know

Last week, we shared with you several "cool and fun" commands to get comfortable and confident with the Linux command-line. In our quest to further aid Linux users with mastery of the command line, or CLI, we present you with a variety of command-line utilities essential for all Linux users, regardless of proficiency level.

What’s New in Ubuntu 20.04 LTS “Focal Fossa”

Ubuntu 20.04 LTS is out now! This is the successor to Ubuntu 18.04, which was released in April 2018 and still has three years of official support left. Code-named Focal Fossa, the new edition has all the bells and whistles included in it, making it one of the best Ubuntu releases yet. Let's find out more.