VirtualBox remote access

VirtualBox supports RDP (Remote Desktop Protocol), which can be enabled by the following steps.

  1. Power off the Guest machine (doesn’t work in saved state).
  2. Click “Settings” to configure the settings for the VM.
  3. Select the Remote Display tab, check “Enable VRDP Server”.
  4. If you’re on Windows you might need to change the server port because it may conflict with the Remote Desktop for Windows.
  5. Click “OK”.

Start the VM, and run “mstsc /v:hostname:port” from another box to Remote Desktop into the VM.

What I’ve experienced is that the mouse speed is not synchronized, so it becomes difficult to navigate even when I change the mouse sensitivity to be approximately the same. I also haven’t figure out how to have authentication with this method.

Another possible way I’ve yet to succeed is to use Ubuntu’s built in vnc server.

Oracle lightweight client

I needed an Oracle client to do some quick tests on a database server (see the next post), something like SQL Plus. But it felt too heavy for me to install the official client. So I went out looking for an alternative, something that’s standalone, very light to install and use. Of course it should be free.

http://www.sqlpal.com/

SQLPal is a perfect match – it’s free (for use), it’s standalone, just unzip and use (no install), works just like SQLPlus. In addition it has a schema browser to dig into the database easily, supports command history, and happens to be implemented in Java. The Java part has no added advantage though, it wouldn’t make a difference if it were in C++ or Python.

EDIT: I just realized the last update to the program was in 2004, evident from the website as well as the files extracted from the zip. Is it bad that there are no updates? Or it’s just a good program that needs no updates?

insert into (select) with oracle sequence

Colleague needed some SQL today for an upgrade script. Needed to add default data to entities that didn’t have a specific parameter.

As usual I reduced the problem to a snippet. Although he was trying to squeeze it into a single command with INSERT INTO (SELECT…), due to time constraints I felt a stored proc was faster to get over it. Maybe someone can post the single command here.

In this case the TestTable already had some data, with refids 1, 2, and 3. Ref 2 already had the xyz param, but the others don’t. So the task is to add the field to all other refids, using the given TestSeq.


CREATE SEQUENCE TestSeq START WITH 7;

CREATE TABLE TestTable (
	id NUMBER PRIMARY KEY,
	refid NUMBER,
	param VARCHAR2(64),
	other NUMBER
);

INSERT INTO TestTable VALUES(1, 1, 'abc', 0);
INSERT INTO TestTable VALUES(2, 1, 'def', 0);
INSERT INTO TestTable VALUES(3, 2, 'abc', 0);
INSERT INTO TestTable VALUES(4, 2, 'xyz', 0);
INSERT INTO TestTable VALUES(5, 3, 'abc', 0);
INSERT INTO TestTable VALUES(6, 3, 'def', 0);

DECLARE
	newid TestTable.id%type;
	CURSOR dataCursor IS
		SELECT UNIQUE refid, other FROM TestTable WHERE refid NOT IN 
		(SELECT refid FROM TestTable WHERE param = 'xyz');
BEGIN
	FOR dataRow IN dataCursor
	LOOP
		SELECT TestSeq.nextval INTO newid FROM DUAL;
		INSERT INTO TestTable VALUES(newid, dataRow.refid, 'xyz', dataRow.other);
	END LOOP;
END;
/

VirtualBox + Ubuntu + SSH + x11

My hands got itchy today, so I thought of having Unix available remotely, since I do almost everything remotely. I had an old version of VirtualBox (1.6 I think) installed on one of my (remote) Windows box, so I downloaded an Ubuntu 8.10 image and threw it in as a guest. It installed perfectly, and had immediate network access, but the guest additions wouldn’t work. At first it appeared to be a privilege problem, so I went to Terminal and ran the following:

cd /media/cdrom
sudo ./VBox-LinuxAdditions.run

and it failed with an Xorg can’t be installed error. So I pulled the new VirtualBox 2.1.2 and did the same thing, this time it passed without a glitch. The additions are like “drivers” for the VirtualBox “hardware”, giving the guest a larger screen resolution than 800×600.

SSH was a breeze too, with this line:

sudo apt-get install openssh-server

Now problem 2 was getting the Guest machine to accept incoming connections. And this guy gave the best solution for me:

> cd \Program Files\Sun\xVM VirtualBox
> VBoxManage setextradata Intrepid 
VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/HostPort 22
> VBoxManage setextradata Intrepid 
VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/GuestPort 22
> VBoxManage setextradata Intrepid 
VBoxInternal/Devices/pcnet/0/LUN#0/Config/ssh/Protocol TCP

This sets up port forwarding such that incoming connections on port 22 on my Windows host will go into the Ubuntu guest, which hosts the SSH server. All was good, after a VM restart and I could PuTTY in smoothly.

Next, problem 3. I had Xming installed, but wasn’t very sure how to use it. I had hoped it wouldn’t be difficult to use or configure. Fortunately, Wikipedia had a nice link to a video tutorial for my exact situation.

The steps:

  1. Install Xming with Portable PuTTY. Make sure the Xming server is started.
  2. On the Intrepid guest, edit /etc/ssh/sshd_config, search and make sure “X11Forwarding yes” is uncommented. For my case this was already forwarded by default, so I didn’t even bother to restart my sshd.
  3. Fire up your PuTTY, go to the SSH > X11 tab, Enable X11 forwarding and specify “localhost:0” as the X display location. Connect to the Ubuntu guest.
  4. Start up a GUI application, such as “gedit &”.

In X11, the client is the Unix machine, and the server is the display where the GUI will appear.

Now I have what I wanted, it was fun, I hope some point in time I’d need such a configuration. Probably when I need quick Unix access for testing. Otherwise it’ll be for helping to answer other people’s Unix questions!