Access VirtualBox SSH and Web Server

One of the thing that differs VirtualBox from Microsoft’s Virtual PC is that VB puts guest on a subnet of the computer that you are working on. This means that it cannot be directly accessed from other computers on your network.

To enable access, you need to configure your computer to allow ports to be forwarded to the guest. Thankfully, this is quite straightforward with the VBoxManage tool, and Allister Sanchez covers it well here: Additions and SSH Access to a VirtualBox Guest.
I’m assuming that your Vitual Machine is called MyVBoxSystem. Replace this with the name of your VM.

To enable SSH:

On the host computer, run the following commands:

<code>VBoxManage setextradata MyVBoxSystem "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" 22
VBoxManage setextradata </code><code>MyVBoxSystem</code><code> "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" 22
VBoxManage setextradata </code><code>MyVBoxSystem</code><code> "VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" TCP
</code>

This is essentially telling VirtualBox to map any access on port 22 (the host port) to 22 on the guest. On a Windows system, this is fine as you are unlikely to be running an ssh server. If you are though, just change the HostPort parameter to a port that you know is free.

To enable HTTP:

<code>VBoxManage setextradata </code><code>MyVBoxSystem</code><code> "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/HostPort" 80
VBoxManage setextradata </code><code>MyVBoxSystem</code><code> "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/GuestPort" 80
VBoxManage setextradata </code><code>MyVBoxSystem</code><code> "VBoxInternal/Devices/pcnet/0/LUN#0/Config/http/Protocol" TCP</code>

Once again, we’re passing TCP ports forward. If you already have a web server installed such as Apache or IIS, then you will probably need to change the HostPort to something like 8080.

Make sure that your VM isn’t running when you run these commands. To check that the settings are saved, you can run the following command:

<code>VBoxManage getextradata MyVBoxSystem enumerate</code>

Alternatively, open up the VM .xml file which is found in .VirtualBox/Machines/MyVBoxSystem/MyVBoxSystem.xml. The settings are found in the ExtraData node:

&lt;ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/HostPort" value="8080"/&gt;
&lt;ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/GuestPort" value="80"/&gt;
&lt;ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/apache/Protocol" value="TCP"/&gt;
&lt;ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort" value="222"/&gt;
&lt;ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort" value="22"/&gt;
&lt;ExtraDataItem name="VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol" value="TCP"/&gt;

Getting that SQL Server 2008 to Work out of the box

I had to set up a new SQL Server database, which I haven’t done in a while as I tend to focus my efforts on mySQL. Nevertheless I needed to get grip on a new site to migrate.

After setting most things up, I managed to get to a point where the database wasn’t starting.

Microsoft OLE DB Provider for SQL Server error ‘80004005’

[DBNETLIB][ConnectionOpen (PreLoginHandshake()).]General network error. Check your network documentation.

I really love unhelpful messages. Anyway, after some head scratching I found an article on on the Microsoft Forums from a chap with a similar issue.

To fix the problem, I loaded up the SQL Server Configuration Manager, and expanded SQL Server Network Configuration. Under Protocols for MSSQLSERVER (this is the instance name of the server), I enabled TCP/IP. The error went away. Tada!

I suppose it would help to read the documentation thoroughly – but I got to where I needed to be anyway. I imagine that it makes sense to disable TCP/IP connections until you’re happy that the server is secure. Even so, I was making connections from the localhost, so I would have expected it to work.

Stop Windows Server 2003 Hanging When Installing Updates

Some of the servers that I manage in locations have a nasty habit of hanging on the final stage of rebooting when trying to apply Windows Updates automatically.

In most locations, I use WSUS to deploy updates around the site which is OK, but when it comes to servers problems arise.

After roaming around on the internet, I found a useful thread at EggHeadCafe which describes the problem I’m having. Apparently, turning off the default user screensaver using the following registry key will solve the problem:

HKEY_USERS\.DEFAULT\control panel\screensaveractive
Set the value to 0

This would make sense, as there is a similar problem in Windows XP where if you try to shutdown the system with the power button (or an update) while the screen saver is active, the system will shutdown until the screensaver is turned off by touching the keyboard or mouse.

I’ll find out if this works in a month’s time!

EDIT: Just logged onto one of my servers with this change and it works a treat.

Trouble installing Sharepoint on a fresh Windows Server 2003 SP2

When installing Sharepoint 3.0 Service Pack 1 onto a fresh Windows Server 2003 installation, you can sometimes fall foul of Sharepoint complaining that ASP.net 2 is not installed:

“This product requires ASP.NET v2.0”

I found the solution over at Sharepoint Blogs. Run the following command on the server:

<code> C:\Windows\Microsoft.net\Framework\v2.0.50727\Aspnet_regiis.exe -i </code>

This will register .NET 2 with IIS and you should be able to use Sharepoint properly from that point on.

Creating a Bootable Windows Setup Disc with Linux

It’s quite annoying having to create Windows installation discs.

One thing I find is that every single time I do it – I keep having to check the internet, so here’s a note of the important bits.

  1. Extract the service pack
    <code>servicepack.exe /extract:C:\SP\</code>
  2. Integrate the service pack with the copied installation disc
    <code>update.exe /integrate:C:\OS_source\</code>
  3. Extract the boot image from the CD and copy it into the new O/S directory
  4. Create an iso with mkisofs
    <code>mkisofs -b bootimage.bin -hide bootimage.bin -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -iso-level 2 -J -l -D -N -joliet-long -relaxed-filenames -V "NRMSVOL_EN" -o newCD.iso C:\OS_source\</code>

Creating the ISO works in both Windows (with a 32-bit version of mkisofs) and Linux.

Hiding the tricky PDF data

Sometimes, you don’t want people reading the fine detail on a PDF document. Especially if you’re lying about when the document was created.

Can you image the conversation?

“Hey, Jeff – I got your report on the bug monsters.”

“No worries, Dave. Just annoying when the email goes missing like that.”

“Er, yeah. By the way – I checked the document summary and it said you only created it an hour ago.”

“Ummmmmmmmmmmm…”

Well, fear not! Help is here! After spending about an hour searching for a useful open source tool, jPDFtweak came to the rescue!

To us this very effective tool, simply download onto your computer and unzip the files. Once done, you can run the application with the following command:

<code>java -jar jpdftweak.jar</code>

Once loaded, you can open a PDF on the import tab

Now,

  • Click the Document Info tab
  • Tick the Change Document Info box
  • Click Load from Document

All the document data that is in the file is now loaded into jPDFtweak. Just double-click on the bits of data that you want to change, and type in the new data.

Once done, click on the Output tab, give your new PDF a name and then click Run.

Yeah, baby!