Skip to content

Instantly share code, notes, and snippets.

@crsuarez
Forked from wacko/gist:5577187
Last active January 14, 2021 05:40
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crsuarez/5a066638a805e46b448acebd4f5fe8d1 to your computer and use it in GitHub Desktop.
Save crsuarez/5a066638a805e46b448acebd4f5fe8d1 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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
Copy link

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

@nickaroot
Copy link

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

@linsinan1995
Copy link

solved, thanks!

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