Local access to a VirtualBox Instance
How to ssh to a VirtualBox instance running on your local host
By default, a VirtualBox setup uses NAT for networking. That means that the guest has access to the internet, but not to the host it is running on, nor does the host have access to the guest.
This makes it hard to do certain types of development, especially web development, as it forces you to run a web browser inside the guest as well as a full development setup. We would much prefer to run a very slim guest and use ssh to get in from the outside.
The first step is to go into the VirtualBox configuration for your host and add a second network adapter. Set it to be attached to "Host interface" and set the interface name to "tap0".
Install uml-utilities on the host using apt-get. Then edit /etc/network/interfaces and add:
auto tap0
iface tap0 inet manual
up ifconfig $IFACE 172.16.1.1 netmask 255.255.255.0 up
down ifconfig $IFACE down
tunctl_user username
Replace "username" with your user name. Bring the interface up with "ifup tap0". Add yourself to the vboxusers and uml-net groups to ensure you have access to /dev/net/tun. You may have to log out and back in to actually gain group membership to these groups.
Now start your guest and configure the second network interface with ip 172.16.1.2 and netmask 255.255.255.0. You should now be able to access the guest from the host using the ip 172.16.1.2.

