How To Install and Enable SSH on Ubuntu 18.04

How To Install and Enable SSH on Ubuntu 18.04 – Secure Shell (SSH) is a cryptographic network protocol used for secure connections between clients and servers.

In this tutorial, I will show you how to install and enable SSH on Ubuntu Desktop operating system. Enabling SSH will allow you to remotely or remotely connect to your Ubuntu computer and securely transfer files or perform administrative tasks.

Condition

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

How to Enable SSH on Ubuntu

The SSH server is not installed by default on Ubuntu desktop systems but can be easily installed from the standard Ubuntu repositories.

To install and enable SSH on your Ubuntu system, perform the following steps:

Open your terminal by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon and install the package openssh-server by typing:

$ sudo apt update
$ sudo apt install openssh-server

Enter the password when prompted and enter it to continue the installation.

ssh on ubuntu 1

After the installation is complete, the SSH service will start automatically. To verify that the installation was successful and the SSH service is running type the following command which will print the SSH server status:

$ sudo systemctl status ssh

You will see something like Active: active (running) :

ssh on ubuntu 2

Press to return to the command line prompt.

Ubuntu comes with a firewall configuration tool called UFW. If a firewall is enabled on your system, make sure to open the SSH port:

$ sudo ufw allow ssh

Now that SSH is installed and running on your Ubuntu system, you can connect via SSH from any remote computer. Linux and macOS systems have an SSH client installed by default. If you want to connect from a Windows computer then you can use an SSH client like PuTTY.

Connecting to SSH Via LAN

To connect to your Ubuntu computer via LAN, you just need to enter the following command:

$ ssh username@ip_address

Change the username with the actual username and ip_address with the IP Address of the Ubuntu computer where you installed SSH.

If you don’t know your IP address, you can easily find it using the ip command:

$ ip a

How To Install and Enable SSH on Ubuntu 18.04

As you can see from the output, the system IP address is 192.168.121.111 .

Once you find the IP address, log in to the remote computer by running the following ssh command:

$ ssh centerklik@192.168.121.111

When you connect via SSH for the first time, you will see a message that looks like this:


		OutputThe authenticity of host '192.168.121.111 (192.168.121.111)' can't be established.ECDSA key fingerprint is SHA256:Vybt22mVXuNuB5unE++yowF7lgA/9/2bLSiO3qmYWBY.Are you sure you want to continue connecting (yes/no)?
	

Type yes it and you will be asked to enter a password or password.

	OutputWarning: Permanently added '192.168.121.111' (ECDSA) to the list of known hosts.centerklik@192.168.121.111's password:

Once you enter your password, you will be greeted with a message similar to the one below.

	OutputWelcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-33-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: .

You are now logged into your Ubuntu computer.

How to Connect to SSH Over the Internet

To connect to your Ubuntu computer via the Internet, you will need to know your public IP Address and configure your router to receive data on the port 22 and send it to the Ubuntu computer where SSH is running.

To determine the public IP address of the computer you are trying to SSH on, simply visit the following URL: https://ifconfig.co/ip.

When setting up port forwarding, each router has a different way of setting up port forwarding. You should consult your router’s documentation on how to set up port forwarding. In short, you need to enter the port number on which the request will be made (default SSH port is 22) and the private IP address you found earlier (using the ip a command) of the computer on which SSH is running.

Once you’ve found the IP address, and configured your router, you can log in by typing:

$ ssh username@public_ip_address

If you expose your computer to the Internet, it is a good idea to implement some security measures. The most basic is configuring your router to accept SSH traffic on non-standard ports and to forward it to port 22 on the computer running the SSH service.

You can also set up SSH key based authentication and connect to your Ubuntu computer without entering a password.

How to Disable SSH on Ubuntu

If for some reason you want to disable SSH on your Ubuntu computer, you can stop the SSH service by running:

$ sudo systemctl stop ssh

To start it again run:

$ sudo systemctl start ssh

To disable the SSH service to start during system boot:

$ sudo systemctl disable ssh

To enable it again type:

$ sudo systemctl enable ssh

Conclusion

You have learned how to install and enable SSH on your Ubuntu 18.04. You can now log into your computer and perform common sysadmin tasks via the command prompt.

By default, SSH listens on port 22. Changing the default SSH port adds an extra layer of security to your server by reducing the risk of automated attacks.

If you manage multiple systems, you can simplify your workflow by defining all your connections in the SSH configuration file.

Secure Shell (SSH) is a cryptographic network protocol used for secure connections between clients and servers.

In this tutorial, I will show you how to install and enable SSH on the Ubuntu Desktop operating system. Enabling SSH will allow you to remotely or remotely connect to your Ubuntu computer and securely transfer files or perform administrative tasks.

Condition

Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges.

How to Enable SSH on Ubuntu

The SSH server is not installed by default on Ubuntu desktop systems but can be easily installed from the standard Ubuntu repositories.

To install and enable SSH on your Ubuntu system, perform the following steps:

Open your terminal by using the Ctrl+Alt+T keyboard shortcut or by clicking on the terminal icon and install the package openssh-server by typing:

$ sudo apt update
$ sudo apt install openssh-server

Enter the password when prompted and enter it to continue the installation.

After the installation is complete, the SSH service will start automatically. To verify that the installation was successful and the SSH service is running type the following command which will print the SSH server status:

$ sudo systemctl status ssh

You will see something like Active: active (running) :

Press to return to the command line prompt.

Ubuntu comes with a firewall configuration tool called UFW. If a firewall is enabled on your system, make sure to open the SSH port:

$ sudo ufw allow ssh

Now that SSH is installed and running on your Ubuntu system, you can connect via SSH from any remote computer. Linux and macOS systems have an SSH client installed by default. If you want to connect from a Windows computer then you can use an SSH client like PuTTY.

Connecting to SSH Via LAN

To connect to your Ubuntu computer via LAN, you just need to enter the following command:

$ ssh username@ip_address

Change the username with the actual username and ip_address with the IP Address of the Ubuntu computer where you installed SSH.

If you don’t know your IP address, you can easily find it using the ip command:

$ ip a

As you can see from the output, the system IP address is 192.168.121.111 .

Once you find the IP address, log in to the remote computer by running the following ssh command:

$ ssh centerklik@192.168.121.111

When you connect via SSH for the first time, you will see a message that looks like this:


		OutputThe authenticity of host '192.168.121.111 (192.168.121.111)' can't be established.ECDSA key fingerprint is SHA256:Vybt22mVXuNuB5unE++yowF7lgA/9/2bLSiO3qmYWBY.Are you sure you want to continue connecting (yes/no)?
	

Type yes it and you will be asked to enter a password or password.

	OutputWarning: Permanently added '192.168.121.111' (ECDSA) to the list of known hosts.centerklik@192.168.121.111's password:

Once you enter your password, you will be greeted with a message similar to the one below.

	OutputWelcome to Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-33-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: .

You are now logged into your Ubuntu computer.

How to Connect to SSH Over the Internet

To connect to your Ubuntu computer via the Internet, you will need to know your public IP Address and configure your router to receive data on the port 22 and send it to the Ubuntu computer where SSH is running.

To determine the public IP address of the computer you are trying to SSH on, simply visit the following URL: https://ifconfig.co/ip.

When setting up port forwarding, each router has a different way of setting up port forwarding. You should consult your router’s documentation on how to set up port forwarding. In short, you need to enter the port number on which the request will be made (default SSH port is 22) and the private IP address you found earlier (using the ip a command) of the computer on which SSH is running.

Once you’ve found the IP address, and configured your router, you can log in by typing:

$ ssh username@public_ip_address

If you expose your computer to the Internet, it is a good idea to implement some security measures. The most basic is configuring your router to accept SSH traffic on non-standard ports and to forward it to port 22 on the computer running the SSH service.

You can also set up SSH key based authentication and connect to your Ubuntu computer without entering a password.

How to Disable SSH on Ubuntu

If for some reason you want to disable SSH on your Ubuntu computer, you can stop the SSH service by running:

$ sudo systemctl stop ssh

To start it again run:

$ sudo systemctl start ssh

To disable the SSH service to start during system boot:

$ sudo systemctl disable ssh

To enable it again type:

$ sudo systemctl enable ssh

Conclusion

You have learned how to install and enable SSH on your Ubuntu 18.04. You can now log into your computer and perform common sysadmin tasks via the command prompt.

By default, SSH listens on port 22. Changing the default SSH port adds an extra layer of security to your server by reducing the risk of automated attacks.

If you manage multiple systems, you can simplify your workflow by defining all your connections in the SSH configuration file.