Shutdown your VM and do:
VirtualBox > Settings > Network > Add (you will get vboxnet0
)
On a terminal ifconfig
will show you new interface vboxnet0
VM's Settings > System > check "Enable I/O APIC." VM's Settings > Network > Adapter 2 > host-only vboxnet0
Install OpenSSH Server
Edit /etc/network/interfaces
file to append the following lines:
auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0
Run sudo ifup eth1
from the Ubuntu command line.
SSH server should be up and running. Switch to your host terminal and enter ssh 192.168.56.10
sources:
I had some trouble with this on my Ubuntu 18.04, which uses netplan instead of /etc/network/interfaces
Instead, I modified /etc/netplan/50-cloud-init.yaml to the following (The 192.168.99.2 is the static IP address I chose.)
After editing the file, run
sudo netplan try
That will allow you to verify it's working before changing the virtual machine's network settings.