VirtualBox Host ssh to Guest

First, you'll have to create the vboxnet0 interface.

VirtualBox > File > Preferences > Network > Host-only Networks > Add (you will get vboxnet0)

Then, run this on the host machine. You'll see a new interface, vboxnet0, appeared.

ifconfig

Shutdown your VM and do:

VM's Settings > System > check "Enable I/O APIC."
VM's Settings > Network > Adapter 2 > host-only vboxnet0

Start VM, on guest run

ifconfig

and check ip

Check these links:

  1. https://forums.virtualbox.org/viewtopic.php?f=8&t=40076
  2. http://www.wiredrevolution.com/virtualbox/setup-ssh-access-between-virtualbox-host-and-guest-vms

There is also solution for NAT but I haven't checked it.

  • http://www.eldemonionegro.com/blog/archivos/2008/05/18/howto-access-a-virtualbox-guest-machine-throught-ssh-or-how-to-port-forwarding

Configuring port forwarding with NAT in your host machine

VBoxManage modifyvm "VM name" --natpf1 "guestssh,tcp,,2222,,22"

connect to your linux via the port 2222 of your host machine

ssh -l -p 2222 localhost

For host-only networking with static ip check this:

https://stackoverflow.com/questions/5906441/how-to-ssh-to-a-virtualbox-guest-externally-through-a-host/27152153#27152153

It's for Solaris 10 and Ubuntu 16.04 but should be easy to adapt.


Between two Linux machines (a 32-bit Ubuntu host and a 64-bit Ubuntu VM), I managed to get ssh working using this Port Forwarding:

enter image description here

Then from your host system run

ssh -p 5679 127.0.0.1

Substitute 5679 with the "Host Port" entered into the Port Forwarding Rules.