How to setup and enable SSH in Ubuntu Virtual Box

VirtualBox is a program used to run and easily transition between several OS on your operating system. It is particularly helpful in establishing connections over networks. Secure Shell is a cryptographic network protocol that securely operates and connects a client to a server over an unsecured network. The data needs to be cryptographically secure before sending it over the network to avoid man-in-the-middle attacks. Besides, you will need to enable SSH while interacting with Virtual Machines for security reasons. We will discuss installing and enabling SSH in Ubuntu virtual box to establish a secure connection between the hosts.

What is SSH?

Sponsored

SSH (Protect Shell) is the open protocol used to secure the less complicated and costly network connection that hardware-based VPN solutions provide or, in other words, authentication, encryption & data integrity to secure the network. We gain several features over SSH, such as secure command-shell, secure file transfer, and remote access through a secure tunnel to a range of TCP/IP applications.

Besides host authentication and data encryption & integrity, it also has additional benefits such as pre-encryption compression, which may considerably lower data encryption computational costs.

What are Ports?

Ports are an abstraction that may communicate programs utilizing various protocols. Apart from transportation layer protocols like TCP, UDP, SMTP, ports are utilized. A port number is assigned to various services; for example, HTTP uses TCP and UDP port 80. By using port numbers, a pair of systems allow the same transport protocol to open numerous sockets.

What is NAT?

Network Address Translation stands for NAT.

As the name implies, NAT is employed to translate the address on an end of a private network created by a user that points to a location that is allegedly in a private network.

Steps to Setup and Enable SSH

Step1: Open your virtual box. Click on Settings and go to Network.

Step2: Choose Adapter

Enable the Network Adapter that is free and Select the NAT network.

Step3:
Open advanced options and click on port forwarding
A tab appears that has some fields, as shown in the next step.

Sponsored

Step4: Add a new entry as per the below instructions after clicking on the + button in this tab.

Name: ssh
Protocol: TCP
Host Port: x
Guest Port: y
where x and y are the same port numbers.

After this, you will see a new entry in the tables with the details you filled in.

Step5: Install SSH
The Ubuntu desktop system does not install the SSH server by default but is easy to install via regular Ubuntu repository systems.

The following commands will install SSH:

sudo apt update
sudo apt install openssh-serve

Step6: Connect to SSH
Type the following command to connect with your guest

$ ssh -p  <username>@127.0.0.1

Enter the password if prompted, and you will get connected to the virtual machine.

See also  How To Set Up CakePHP For Production: Ubuntu 16.04

To disable SSH in your machine, run:

sudo systemctl stop ssh

To enable it when it’s disabled, run:

sudo systemctl enable ssh

Conclusion

We learned how to install SSH on your Ubuntu virtual machine. As we discussed, SSH is a useful tool to establish secure communication between the client and server over an unsecured network. Without the proper setup of SSH connection, your applications can get affected by a man-in-the-middle attack where an attacker can access your data over the network. SSH uses RSA and other asymmetric encryption algorithms to encrypt and decrypt the data sent over the network. Securing your data becomes more important when exchanging data like bank details and passwords over the network. The absence of security can lead to a big loss to both client and the company. Modifying the default SSH port will increase your server’s security by lowering the danger of automated cyber-attacks.

Leave a Comment

Only people in my network can comment.