How to SSH to a VirtualBox from macOS

By: Kevin | January 17, 2017

On macOS (host):

Shutdown your VM and do:

  1. VirtualBox > Settings > Network > Add (you will get vboxnet0)
  2. Network:
  3. Mask:
  4. On a terminal ifconfig will show you new interface vboxnet0
  5. VM’s Settings > System > check “Enable I/O APIC.” VM’s Settings > Network > Adapter 2 > host-only vboxnet0

On Ubuntu 16.04.1 (guest):

Install OpenSSH Server, sudo apt-get install ssh

Run ip link, You should see a list like lo, enp0s3 and enp0s8 or something to that effect. Use that interface name for the below.

Edit /etc/network/interfaces file to append the following lines:

# The loopback network interface
auto loiface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
# The static ip to ssh to
auto enp0s8
iface enp0s8 inet static

Run sudo ifup enp0s8 or sudo shutdown -r now from the Ubuntu command line. SSH server should be up and running.

Switch to your host terminal and enter ssh user@