How to Setup SSH access between VirtualBox Host and Guest VMs

Posted: 11/03/2012 in Virtualbox
Tags: ,

Wanted to install a test virtual machine on my Desktop pc for server and ispconfig proposes. Test new things, new software etc.
The problem was that the clipboard between host and virtual machine does not works if you haven’t set up X. So i google it for the solution and i wrote a simple tutorial.

INSTALL ORACLE VIRTUALBOX

Go to
http://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html
download virtual box for your machine
Debian 6.0 (Squeeze) virtualbox-4.1_4.1.6-74713~Debian~squeeze_amd64.deb
and Oracle VM VirtualBox Extension Pack
For use with Version 4.1.6 only
All Platforms (Windows, Mac OS X, Solaris and Linux) Oracle_VM_VirtualBox_Extension_Pack-4.1.6-74713.vbox-extpack

after go into your download folder and run as root

dpkg -i virtualbox-4.1_4.1.6-74713~Debian~squeeze_amd64.deb

after installation open the
Oracle_VM_VirtualBox_Extension_Pack-4.1.6-74713.vbox-extpack
with virtualbox (double click)
to install the Oracle VM VirtualBox Extension Pack

it will also ask you the root password during the installation

to have usb support between the the host and the guest machines edit /etc/fstab and add

usbfs /proc/bus/usb usbfs defaults,devmode=666 0 0

then do a

mount -a

as root from your terminal

The Linux installers create the system user group vboxusers during installation. Any system user who is going to use USB devices from VirtualBox guests must be a member of that group. A user can be made a member of the group vboxusers at the command line with

sudo usermod -a -G vboxusers username

now
open virtualbox
go to File–>Preferences–>Network and click on the “Add Host-only network (Ins)
it will create automatically a “vboxnet0” network
Click to OK to save changes

Add a new virtual machine and proceed with installation. I installed Debian 6.
After installation boot the new v.machine and then power off it.

Now go with your mouse on your virtual machine
Right-click –> Settings
Go to Network — click on the second tab “Adapter 2”
check the “Enable Network Adapter” and choose from the drop-down Attached to: Host-only Adapter
It will automatically choose the “vboxnet0” in the Name field
Click to OK to save changes

Now open a terminal on your host maschine and execute

ifconfig

you will see something like this

vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00
inet addr:192.168.56.1 Bcast:192.168.56.255 Mask:255.255.255.0

keep in mind the 192.168.56.1

Bootup your virtualmachine
login as root and run

Code:

pico /etc/network/interfaces

add these lines in the bottom

auto eth1
iface eth1 inet static
address 192.168.56.10
netmask 255.255.255.0

the address 192.168.56.10 is based in the ifconfig results on you host machine

after this close and save
run in terminal

ifup eth1

Now go to your root machine’s console and login with ssh to your guest machine

ssh user@192.168.56.10

Those tested on a debian 6 host and also a debian 6 guest

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s