NewsLinuxsecurity

How to enable SSH on Linux Ubuntu (Easy step by step guide)

OpenSSH, or SSH, is a command-line communication protocol used for operating systems like Linux and Unix. This useful tool is an acronym for Secure-Shell and was first introduced in 1995. The tool was upgraded four years later in 1999 so today all Linux operating systems support this protocol. After installing Ubuntu, it is necessary to correctly install and configure this program. Installing this protocol on Ubuntu allows users to remotely and securely access a device on which this protocol is installed, and to transfer the files they want or perform necessary actions. It’s worth mentioning that the SSH protocol encrypts all communications, thereby enhancing data security. People who are new to the Linux operating system should install and configure SSH on their devices before anything else. In this article, we intend to familiarize you with installing and setting up this protocol in Ubuntu. So stay with us until the end of this article. READ More: How to obtain IP and MAC Addresses in Ubuntu?

What is an SSH tunnel and what is its application?

As we mentioned, SSH is a network security protocol installed on the Linux operating system. This protocol securely transfers data through a communication tunnel. An SSH tunnel is a technique that attackers can use to bypass firewall restrictions. With this technique, users’ IP addresses remain hidden in cyberspace, so no one can monitor or eavesdrop on them. One of the reasons for using SSH tunneling is the problems that exist with the use of public IPs, as hackers can easily access any IP address. The design and development of SSH Tunneling have been able to eliminate a significant amount of security issues with public IP addresses. Therefore, those who use Ubuntu today should install this protocol.

What is the SSH command?

SSH, an acronym for Secure Shell, is an encrypted network protocol that can be installed on Linux and Unix operating systems. This protocol is used for a secure connection between the user and the server. Therefore, the installation and setup of this protocol on the Ubuntu device are very necessary and essential for Linux users. The installation of the SSH protocol allows users to connect remotely and securely to the Ubuntu device. This protocol can encrypt all communications between the user and the server. Therefore, transferring files and executing any instructions using them are completely secure. SSH is not installed by default on Ubuntu devices and must be manually installed. To install it, users must have Sudo privileges, otherwise, they can easily install this network security protocol by activating the root account in Ubuntu.

How to install ssh on Ubuntu Linux

  1. The first step you need to take is to install the SSH protocol on Ubuntu. To do this, simultaneously press Ctrl + Alt + T or click on the terminal symbol to open the terminal, then install the OpenSSH-server package:
sudo apt update
sudo apt install openssh-server

If necessary, enter your password and enter ‘Y’ to continue with the installation.

How to install ssh on Ubuntu Linux
  1. After installing SSH on Ubuntu, SSH starts automatically. The command allows you to verify the success of the installation by printing the SSH status:
sudo systemctl status ssh

What you see should look like ‘Active: active’. To return to the command line, press the ‘Q’ key.

  1. Keep in mind that Ubuntu has a firewall configuration tool called UFW. If the firewall is active on your system, allow access to the SSH port using the following code:
sudo ufw allow ssh

Now SSH is easily installed and running on your Ubuntu system or server, and you can use it to connect from any device and anywhere.

Note that Linux and macOS systems have the SSH client installed by default. If you want to connect to Ubuntu through Windows, you must use a service that is an SSH receiver, such as Putty.

How to install SSH on Ubuntu via LAN?

To start installing SSH via LAN, just use the following command:

ssh username@ip_address

In ‘ip_address’, enter your IP address. If you don’t know your IP, you can find it using the following code:

ip a
How to install SSH on Ubuntu via LAN?

Once your IP has been determined, use the following command to log in to the remote machine:

ssh linuxize@ ip_address

As soon as your connection via SSH is established for the first time, you will see a message similar to the one below:

The authenticity of host 'ip_address (ip_address)' 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’ and enter your password when requested.

Warning: Permanently added 'ip_address'

linuxize@ip_address's password:

Once you have entered your password, you will see a message similar to the one below, welcoming you to the system:

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

That’s it! You have now logged in to your Ubuntu system.

Install SSH on Ubuntu via the internet

To install SSH on Ubuntu with the help of the internet, the first thing you need to do is connect to your Ubuntu device. For this, you should know your public IP address and set up your router to accept your data on port 22 so you can send it to your Ubuntu device that has SSH installed.

To identify the public IP of the device you want, use this URL: https://api.ipify.org

When it comes to setting up port forwarding, each router has a different way to configure this port, and if you want to set up port forwarding, you should refer to your router’s documentation. Simply put, you should enter the port number where it is requested. The default SSH port number is usually 22, which you can easily change. After entering the SSH port number, enter the private IP address that we previously taught you how to find. After configuring your router, you can use the code below to log in to the system:

ssh username@public_ip_address

Don’t forget that if you are exposing your device to the internet, you should take some security measures. The main action you need to take is to set up your router to accept traffic on a non-standard port and then transfer it to port 22 of the device running the SSH service. By default, Ubuntu will ask for your password to establish an SSH connection.

How to disable SSH on Ubuntu?

If for any reason you have decided against enabling SSH on Ubuntu, you can easily disable this service; just use the following code:

sudo systemctl stop ssh

Of course, you can use the following code to restart it:

sudo systemctl start ssh

The code we have provided below is to disable the SSH service when the system boots:

sudo systemctl disable ssh

To install SSH on Ubuntu, type the following code:

sudo systemctl enable ssh

Conclusion:

In general, we can say that the SSH protocol is a network security tool that can be used to establish a secure connection between two servers over the Internet. Users can easily manage a server remotely and securely using this protocol. In this article, we have reviewed how to install it and some settings for the OpenSSH program. By following the stated steps, you can easily install and run it on the Ubuntu Linux distribution. READ More: How to Share Files on a Network Using SMB Protocol Ubuntu?

Frequently Asked Questions

How can access to the terminal be gained on Ubuntu servers?

To install the SSH protocol, you first need to activate the Linux terminal. You can do this by clicking on the icon of this program. If you prefer, press the three keys Ctrl + Alt + T simultaneously on the keyboard to run the terminal program for you.

How can multiple systems be managed simultaneously with ease?

To run and manage several systems simultaneously and remotely, you can install and run the SSH protocol.

What command should be executed to disable the SSH protocol on the Ubuntu device?

To disable it, just execute the command sudo systemctl stop ssh in the terminal.

What should be done to reactivate the SSH protocol on the server if it has been disabled?

To reactivate the protocol, just execute the command sudo systemctl enable ssh.

keleis andre

Keleis Andre is A tech writer specialising in cybersecurity expert, author, and Manager at SPY24 Company. On this and several other GDPR, MDR, and ethical hacking projects. Hacking, Social Engineering, and Security Awareness Training: My goal is to educate, inform and entertain as I write about my journeys in the tech and cyber space.

Leave a Reply

Your email address will not be published. Required fields are marked *