How to Enable SSH Server on Ubuntu 18.04 LTS

29/12/2020
ssh
SSH server is used to connect to a remote computer using SSH client. The remote computer can be controlled and configured using the SSH client program.  On Ubuntu 18.04 LTS, the SSH server is called OpenSSH server. The OpenSSH server program is available in the official package repository of Ubuntu 18.04 LTS.

In this article, I will show you how to enable SSH server on Ubuntu 18.04 LTS. Let’s get started.

Installing SSH Server on Ubuntu 18.04 LTS:

SSH server program must be installed on the computer that you want connect and control remotely.  Since the SSH server or OpenSSH server package is available in the official package repository of Ubuntu 18.04 LTS, you can easily install it.

First update the package repository cache of your Ubuntu 18.04 LTS operating system with the following command:

$ sudo apt-get update

The package repository cache should be updated.

Now you can install the OpenSSH SSH server program on the remote computer that you want to connect to with the following command:

$ sudo apt-get install openssh-server

Now press y and then press <Enter> to continue.

The OpenSSH SSH server program should be installed.

Installing SSH Client:

You must have SSH client program installed on the computer from which you want to connect to your remote computer using SSH. It should be installed by default on most Linux operating systems these days. But in case you don’t have it installed, I will show you how in this section.

Ubuntu/Debian:

On Ubuntu or Debian operating systems, the SSH client program is available in the official package repository.

You can install SSH client program with the following command:

$ sudo apt-get install openssh-client

It should be installed.

CentOS 7/RHEL 7:

On CentOS 7 and Red Hat Enterprise Linux 7 (RHEL 7), the SSH client package is available in the official package repository as well.

Run the following command to install SSH client program on CentOS 7/RHEL 7:

$ sudo yum install openssh

SSH client program should be installed.

Connecting to the Remote Computer using SSH:

Now that we have SSH server program installed on our remote Ubuntu 18.04 LTS computer, and SSH client program installed on our local computer, we can connect to our remote Ubuntu 18.04 LTS computer from our local computer using SSH.

To connect to your remote computer, you have to know the hostname/domain name or IP address of your remote computer.  If your remote computer is on a public network and it has DNS or domain name configured, the hostname should also be set to your domain name. If that’s the case, you can find the hostname of your remote computer with the following command:

$ hostname

If your remote computer is on the local network or you have a public dedicated IP address that you can connect to, then all you need is the IP address of your remote computer in order to connect to it using SSH.

You can find out the IP address of your remote computer with the following command:

$ ip a

As you can see from the marked section of the screenshot below, the IP address of my Ubuntu 18.04 LTS remote computer is 192.168.199.170. It’s on my local network. Take a note of it.

Now from your local computer, run the following command to connect to your remote computer using SSH:

$ ssh USERNAME@IP_OR_HOSTNAME

NOTE: Here USERNAME is your login user name of your remote computer and IP_OR_HOSTNAME is the IP address or DNS/domain name of your remote computer.

You should see the following prompt if you’re connecting to your remote server for the first time using SSH. Just type in yes and press <Enter> to continue.

Now type in your password for the login USERNAME of your remote computer and then press <Enter>.

You should be connected as you can see from the screenshot below.

Now you can run any command you want on your remote computer from your local computer as you can see from the screenshot below.

$ lsb_release -a

Once you’re done, run the following command to exit out of the remote computer.

$ exit

As you can see, I am disconnected from the remote computer.

Opening SSH Server Port on Ubuntu 18.04 LTS Remote Computer:

The firewall program of Ubuntu 18.04 LTS is called UFW. At times, UFW may be configured on your remote computer to block SSH server connection from other machines.

You can run the following command to open the SSH server port using UFW:

$ sudo ufw allow ssh

The SSH server port should be opened.

Starting SSH Server on System Boot:

Most of the time, you will want your SSH server to start when your computer boots. In that case, the SSH server service must be added to the system startup of Ubuntu 18.04 LTS.

To add SSH server service to your system startup, run the following command:

$ sudo systemctl enable sshd

The SSH server service should be added to the system startup.

That’s how you enable SSH server on Ubuntu 18.04 LTS. Thanks for reading this article.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Enable SSH on Debian 10

You can use SSH to access to your Debian 10 server or desktop remotely. You can install new software packages, configure...
29/12/2020

How and Why to Change Default SSH Port

Secure Shell, also known as SSH is a network protocol which can be used to access the server remotely. Communication taking...
29/12/2020

Arch Linux SSH Server Setup, Customization and Optimization

In this article, I will show you how to install, customize and optimize SSH server on Arch Linux. Let’s get started. Installing...
28/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

Mua Proxy V6 Nuôi Facebook Spam Hiệu Quả Tại Onetcomvn
03/06/2024

Hướng dẫn cách sử dụng ProxyDroid để duyệt web ẩn danh
03/06/2024

Mua proxy Onet uy tín tại Onet.com.vn
03/06/2024

Thuê mua IPv4 giá rẻ, tốc độ nhanh, uy tín #1
28/05/2024

Thuê địa chỉ IPv4 IPv6 trọn gói ở đâu chất lượng, giá RẺ nhất?
27/05/2024