Skip to content

Instantly share code, notes, and snippets.

@cfebs
Created July 4, 2011 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfebs/1063798 to your computer and use it in GitHub Desktop.
Save cfebs/1063798 to your computer and use it in GitHub Desktop.

Virtualbox Ubuntu Server with OpenSSH

What this will get you:

  • A true linux shell without Cygwin on Windows. Essentially an SSH server sitting on your desktop which I have found perfect for web development using a powerful editor like vim or emacs + screen.

Initial Steps

  • Download Virtualbox
  • Grab an image of Ubuntu Server
    • Install using the wizard
    • When you get to the section that allows you to select pre-loaded software, only select OpenSSH. I like using XAMPP to do local PHP development, but if you like you can select LAMPP for a basic stack.

Set bridged mode

Shutdown your server with:

sudo init 0

In Virtualbox, go the settings for your machine, and find the network tab. Change the first adapter to the following:

Attached to: Bridged Adapter
Name: "Name of main network adapter here"

Copied from this great source

First run from your Windows host:

ipconfig

Remember the gateway and network mask

Back on the server:

sudo vim /etc/network/interfaces

Then modify the file to look like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.1.100  <-- ip of your choosing
netmask 255.255.255.0  <-- whatever your windows netmask was
network 192.168.1.255
gateway 192.168.1.1    <-- whatever your windows gateway was

The address IP can be whatever you wish so long as it isn't already taken by another adapter on your network.

Restart Ubuntu and you should be good to go.

Windows Host File

Windows 7 Hosts files will be here:

C:\Windows\System32\drivers\etc\hosts

Open up that file and add a nice alias to your static IP, I called mine devvy

# bunch of crap
#...

192.168.1.100 devvy

Boom, now devvy in your browser or SSH client will point to your server!

Shared Folders

  1. In VirtualBox got to Devices, select Install Guest Additions
  2. sudo mount /dev/cdrom /media/cdrom
  3. cd /media/cdrom
  4. sudo ./VBoxLinuxAdditions.run
  5. Create a new shared folder, select Auto-mount and Make Permanent
  6. Save any work and sudo reboot

This will auto-mount the folder just setup in the /media/sf_{folder-name} directory. Try to navigate to this directory now.

In my case my user did not have access to the folder immediately, so adding your user to the Vbox user should allow you to use the directory

sudo usermod -G vboxsf -a <your-username>

Credits to these fine sources: bulk of guide, permission fix

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