Hi, in this article I am going to simplify how to connect your local host to the Virtual Machine your created using Oracle Virtual Box, using SSH.
it's not an everyday job that you want to connect between your local host and VM, however, sometimes you want to access it and doing stuff from your local host using the terminal, in this article I am going to give you a neat way to setup a SSH connection between the local host and the Virtual Machine.
First of all, I am using Ubuntu 20.04 LTS and I installed virtual box for some practicing on ubuntu - I don't want to miss with my guy actually - and after installing Ubuntu on the virtual machine, I faced a problem while connecting my local host to the VM as most of us do while using VMs over the cloud or connecting to remote servers using SSH.
Below, is the steps in a simplified way to be able to connect to your VM from your local host using SSH
3- once you click on Port Forwarding, a small window will come up with two options on the right (adding a new port forwarding rule, removing a new port forwarding rule).
N.B: I blured my local host IP and the VM IP
4- here comes the tricky part and stick with me please
- under the name field, your will write
- under the protocol field, you will leave it as
- under the host IP, you will write your the IP of the local host (your laptop or PC)
- under the host port, type
3022, I tried
2222but it didn't work for me, so try both.
- under the guest IP, type the IP address of the Virtual machine, the IP is given automatically within the Operating system, so you just need to check the setting of the Operating system #NOT THE SETTINGS OF THE VIRTUAL MACHINE
- under the Guest port, type
- click ok and then ok.
Bingo, That's the first part.
The second part is simply you will go inside the virtual machine, in the virtual environment and type these commands in your terminal to install
ssh server :
sudo apt update
sudo apt install openssh-server
sudo service ssh start
to check that everything is working fine, type:
sudo systemctl status ssh
Congratulations, you are about to make it.
The Last step is to connect from your local host machine to the Virtual Machine using this command.
ssh <username on the Virtual machine>@<local host IP> -p 3022
and just type your credentials, and here you are.
Congratulations, you are now on your VM using your terminal only.
Thank you for your time 🙏️
Please leave your opinion in the comment section, also if there is anything that happened wrong during any step, please let me know, chao ❤️❤️❤️
you can follow me on twitter: https://twitter.com/ahmadzaabal
also you can find me on instagram: https://www.instagram.com/ahmed_a_fahmy/
last but not least,My Linkedin: https://www.linkedin.com/in/ahmedhedia/