Note: This content may be moving. If you have bookmarked it, please update your record to point to http://vdir.us/go/ubuntu-git-vbox.
I have been working with Ubuntu in VirtualBox for a week or two now. At first it was merely an exercise in learning Java, Eclipse and Git but it turns out that with Mono, Linux gets a lot more attractive. More on this later, though! Here are a few notes that I have compiled that would be helpful to those running Ubuntu inside a VirtualBox virtual machine (primarily on a Windows host).
Networking, SSH
If you plan on using Ubuntu as a server of any kind, I suggest using the Bridged network adapter so that the VM looks like a regular PC on the network. Otherwise you will end up fudging with the port forwarding in VBox and inevitably failing (perhaps that is just me). Here is how I set up my Ubuntu VM to enable SSH.
- With the VM off, open the Networking settings in VBox…
- Use Bridged Networking, and the AMD PCNet Fast III adapter. See Chapter 06 of the VBox manual for more info.
- Boot the VM, log on
- Run sudo gedit /etc/network/interfaces. Your file should look like the following. Change your address and gateway IP’s to represent your personal network’s specifics.
auto lo iface lo inet loopback address 127.0.0.1 netmask 255.0.0.0 auto eth0 iface eth0 inet static address 192.168.1.118 netmask 255.255.255.0 gateway 192.168.1.1
- Run sudo gedit /etc/resolv.conf to edit your nameservers. Mine has a single entry: the router.
- Edit your hosts file to add your computer to the IP address. Run sudo nano -w /etc/hosts. I commented out the automatic one and added my own.
# 10.0.2.15 JSUbuntu-Virtual # Added by Network Manager 192.168.1.118 JSUbuntu-Virtual
- Run sudo /etc/init.d/networking restart to apply your changes.
- Run ifconfig to see your changes.
- Check that your configuration works by browsing to a site.
- Now to install SSH, run sudo apt-get install ssh. Note that you may have to run a sudo apt-get update to update the available packages.
- If you have a firewall enabled, configure port 22 to be open. This is the default SSH port.
- If you want it to be public, enable port forwarding on your physical/network router for port 22 and your Ubuntu’s IP.
- On your host machine, download PuTTY
- Run PuTTY, enter IP, smash the enter key.
- Enter your credentials!
Next I will show you how to get up and running with git.