Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SSH between Mac OS X host and Virtual Box guest

On Mac OS (host):

Shutdown your VM and do:
On a terminal:

VBoxManage hostonlyif create
VBoxManage hostonlyif ipconfig vboxnet0 --ip 192.168.56.1
VBoxManage dhcpserver add --ifname vboxnet0 --ip 192.168.56.1 --netmask 255.255.255.0 --lowerip 192.168.56.100 --upperip 192.168.56.200
VBoxManage dhcpserver modify --ifname vboxnet0 --enable

ifconfig will show you new interface vboxnet0.

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

Note:

When you setup the interfaces, choose eth0 as the management one, and attach it as "host only adapter" in virtualbox.

On Ubuntu/Debian (guest):

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

On Centos 6/RedHat (guest):

Create a file called ifcfg-eth1 under /etc/sysconfig/network-scripts directory and append the following lines:

DEVICE=eth1
BOOTPROTO=static
ONBOOT=yes
NM_CONTROLLED=no
HWADDR=08:00:27:0B:04:D6 #HERE COMES THE MAC ADDRESS THAT VIRTUALBOX GENERATED FOR THIS INTERFACE
IPADDR=192.168.56.10
NETMASK=255.255.255.0
GATEWAY=192.168.56.1

In Debian/Ubuntu run sudo ifup eth1 from the Ubuntu command line. In Centos/RedHat run service network restart from the Centos command line.

SSH server should be up and running. Switch to your host terminal and enter ssh 192.168.56.10

sources:

@crsuarez

This comment has been minimized.

Copy link
Owner Author

@crsuarez crsuarez commented Jun 22, 2017

from: http://www.linuxforums.org/forum/red-hat-fedora-linux/193830-missing-ifcfg-eth0-file-centos-6-3-a.html

#] cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
@markph0204

This comment has been minimized.

Copy link

@markph0204 markph0204 commented Jan 19, 2018

As of Debian 9 "Stretch" please note that network interfaces like eth0 are now enp0s8 or similar.

@nickaroot

This comment has been minimized.

Copy link

@nickaroot nickaroot commented Feb 2, 2019

On CentOS 7 network interface eth1 going to be enp0s8 too, check it out (use ip a)

@linsinan1995

This comment has been minimized.

Copy link

@linsinan1995 linsinan1995 commented May 20, 2020

solved, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment