The VM in this walkthrough is Ubuntu 11.10 32bit (“VM”). It is running on my desktop, the physical machine (“PM”) running which runs Windows 7 32 bit as the Host Operting System (“Host OS”).
Things will be a lot easier for you if your username on your VM (“vmuser”), Host OS (“huser”) and remote host (“rmuser”) are the same.
Part 1: Generate RSA keys on your VM, and install them on the remote host
Follow steps 3 and 4 from the Ubuntu community help page, on your VM:
chmod 700 ~/.ssh
ssh-keygen -t rsa
Try sshing from the VM to the remote host. If it does not ask you for a password, then key-generation and installation worked. If not, then you must fix this before continuing.
Part 2: Preparing your VM and setting up an entry in /etc/fstab
- *samba file server
- *[optionally] Install webmin (will make checking user group, and creating/checking home share a lot easier).
- *[optionally] Install the ssh meta-package so that you can ssh between your PM and VM.
Create a folder in home called remotehome.
Create a /etc/fuse.conf and add ‘user_allow_other’ to it:
Check that your VM user is a member of the fuse group.
Add the following line to /etc/fstab:
In a terminal on the VM, type in
mount ~/remotehome to test.
Part 3: Editing your VM’s crontab.
We could have used the ‘auto’ directive in fstab to mount the remote path, however I never got this to run properly within a VirtualBox VM.
An easy work-around is to edit your crontab like this:-
Then add the following line to the bottom of the file:
Save your crontab and reboot your VM to check that this is all working. Check that you can open and create files, and make folders etc.
Part 4: (a) Creating a Samba user and (b) sharing your vmuser home folder
4(a) Creating a Samba User.
Open a terminal on the VM and type the following:
If your huser != vmuser, then you are in for a World of Pain (TM) and need to carry out these additional steps:
Add the following line:
If your huser is part of an Active Directory domain, you need to add that too, i.e.
4(b) Sharing your vmuser home folder.
You need to either use Webmin to create/turn on home shares (make sure it is writable to authenticated users) or do the following in a terminal on your VM:
cp smb.conf smb.conf.bak
mv smb.conf smb.conf.master
If you had to edit the file smbusers, then add the following line to the
Find, and uncomment the following lines:
; comment = Home Directories
; browseable = no
; read only = yes
Change browseable to yes and read only to no.
Add the line
writeable = yes for good measure.
Save your file, quit vim and then do the following:
service smbd restart
Part 5: Setting your VM to launch on start-up
In your Host OS, click on the Start button, click on All Programs, find and right click on Startup and choose “Open”.
Right click anywhere within the new Explorer window, and choose New –> Shortcut.
Enter the following for location of item:
Click Next, call the name something sensible, other then VBoxManage.exe, and click Finish.
Part 6: Give your VM a second NIC, a static IP and expose it to your Host OS
Shut down your VM, open Oracle VM VirtualBox Manager, click on your VM, and click “Settings”.
Click on the Network group, then on the Adapter 2 tab, and enable the Network Adapter. Change “Attached to:” to Host-only Adapter, note the adapter name and then click ok.
Still in VirtualBox Manager, click on File and then Preferences, click on the Network group, click on the adapter named in the previous step and click on edit. Give the adapter a fixed ip of 192.168.56.1 and network mask of 255.255.255.0. The IP address 192.168.56.1 is the IP on which your VM will communicate to your Host OS.
Fire up your VM. Open a terminal and open up your interfaces file with:
Make sure your interfaces file looks exactly like this:
iface lo inet loopback
iface eth1 inet static
Save and close the file and restart the VM’s networking service with:
On your Host OS, edit the file
C:\Windows\System32\drivers\etc\hosts and add the following line:
At this point you should be able to:
- ping your VM from your Host OS with
ping ubuntusvrfrom the command prompt
- ssh into your VM from your Host OS to 192.168.56.10 or ubuntusvr
- browse shares on your VM by opening Explorer and going to \\192.168.56.10\huser or \\ubuntusvr\huser
- if apache, webmin, psql, mysql or any other sort of server is installed on your VM, access it through 192.168.56.10 or ubuntusvr
Part 7: Connecting network drive
In the Host OS, open Windows Explorer, click Tools –> Map Network Drive. Choose any drive and set the folder to \\192.168.56.10\huser OR \\ubuntusvr\huser, make sure ‘Reconnect at logon’ is checked and click on Finished.