How to enable SSH on Ubuntu 18.04

How to enable SSH on Ubuntu 18.04

Enable SSH on Ubuntu 18.04

SSH stands for Secure Shell Service, which enables secure remote login and other network operations. In this tutorial, you will learn how to enable SSH on the Ubuntu desktop. With ssh, you can remotely connect to a computer, access files, and perform administrative tasks.

Prerequisites

Before enabling SSH on Ubuntu 18.04. The server requires a non-root user account with sudo privileges.

Install SSH on Ubuntu

Here, install SSH from the Ubuntu repository. Installing SSH on Ubuntu is very easy.

Update the apt package manager index by entering the following command

sudo apt update

You need to install OpenSSH-Server (OpenBSD Secure Shell) available in Ubuntu Universal Repository. Enter the following command to install the OpenSSH server

sudo apt install openssh-server

You will now be prompted for a password. Just enter your password.

It is started automatically when you install ssh. Print the status of the ssh service to check the installation type following the command in the terminal.

sudo systemctl status ssh

The output is

Output
    Active: active (running) :
Now press q to go back to the terminal.

Editing the SSH configuration file

You can edit the ssh configuration according to your requirements. To edit the SSH configuration, enter the following command:

sudo nano /etc/ssh/sshd_config

If you don’t have nano installed, you can also use the Gedit Text Editor that comes with Ubuntu by default.

sudo gedit /etc/ssh/sshd_config

After editing the file, save and close Gedit.

Use SSH on LAN

After enabling ssh, if you want to connect Ubuntu desktop by LAN, you need to enter the following command in terminal

ssh [email protected]

Replace the username with the Ubuntu desktop username and replace the IP address with the IP address of the machine to connect to.

To get the IP address of the machine, enter the following command

ifconfig

Once you have an IP address, you can connect by typing

ssh [email protected]

When connecting for the first time, a warning is displayed. Enter “yes” to continue.

Now you need to enter the password of the machine you want to connect to and press Enter.

Use SSH on the Internet

First, you need to know the public IP address of the machine to connect to. You can check by entering the following command:

curl ipinfo.io/ip

Enter the following command to connect to the machine

ssh [email protected]_ip_address

Note: If you publish your machine to the Internet, you need to configure your router to accept SSH traffic.

Basic operation of SSH

To start the SSH service, enter the following command

sudo systemctl start ssh

To stop the ssh service, enter the following command

sudo systemctl stop ssh

To enable SSH on Ubuntu, enter the following command:

sudo systemctl enable ssh

Enter to disable SSH service

sudo systemctl enable ssh

Conclusion

Here you have learned how to successfully enable SSH on the Ubuntu 18.04 desktop. If you have a query, don’t forget the comments below.

Sidebar