How to setting an ssh connection on a Virtualbox Ubuntu
How To setting SSH connection to Ubuntu on Virtualbox. How to setting an ssh connection on a Virtualbox Ubuntu.
Create an Ubuntu Virtualbox
Create a new Virtual Machine and check Create a new virtual disk
Name your virtualmachine, select Linux as OS type and Ubuntu (64 bit) as linux version.
Set the virtual RAM at half of the your real RAM, in my case I have 8gb on my laptop, so i give to virtual machine 4gb
Create a new virtual disk:
Select the source for install your Ubuntu OS, select VDI (VirtualBox Disk Image)
Select Dynamic allocation:
Set the size of your virtual Hard Disk and click on create:
Start your Machine:
Select the iso image of ubuntu (You must download it from ubuntu official web site).
Install Ubuntu following the installation wizard:
After have installed Ubuntu, login your virtualmachine ubuntu with username and password inserted during the installation:
sudo apt-get update sudo apt-get install openssh-server
stop your virtualmachine.
Set the net of your virtualmachine:
click on settings & net:
Select NAT as connection and click on advanced, and set as in the picture below.
Click on port forwarding:
and set the SSH parameter:
Host IP: 127.0.0.1
Host Port: 2222
IP Guest: Empty
Port Guest: 22
Start your Virtual Machine:
When your VM is started, open your terminal and try to connect:
ssh [email protected] -p 2222
now you shoud be inside your virtualmachine.
Problems and Possible Solutions:
If you can’t connect try to disable or change settings to ubuntu firewall:
sudo ufw disable
or try to connect to the ip of VM:
click on global tools:
Click on create:
Back to Settings > Network and select adapter 1
Select Adapter only Host.
go inside the VM and get the ip number with ifconfig and get ip address:
In my case the ip is 192.168.56.101
now from terminal I try to connect in ssh to the ip 192.168.56.101
✅ 30s ad