Friday, June 27, 2008

Remote Desktop and VNC in OpenSolaris

After gone for holiday for sometime, I am back to OpenSolaris.

OpenSolaris has Remote Desktop (RD) pre-installed, however RD has its constraints: someone at the local console can see exactly what the remote user is doing, and vice versa. This is sometimes not desirable. For example I have my Solaris box sitting in lab while my cubicle is somewhere else, I don't wish to let everyone in the lab to see what I am doing at my box remotely. Even though I can shut-off or even remove the local console, RD still is not a good solution for remote access. Luckily, Virtual Network Connection (VNC) fits my purposes, though there are some work involved which I shall discuss below.

My set up is as follows: in lab the OpenSolaris box has a hostname of 'Solaris', while in cubicle a Linux box named 'Ubuntu'.

  1. First of all, enable the default Remote Desktop at Solaris. Enabling RD serves two purposes: test the box's network connectivity, and RD is useful for subsequent troubleshooting of the VNC setup. I shall skip RD setup in this post.
  2. Once RD is up and running, goto Solaris and invoke System->Administration->Package Manager. Type 'vnc' in the search box and you should see two packages: One is vncviewer, another is vncserver. Install both.
  3. At command line, run vncserver as follows:

  4. vncserver

    If this is your first time running vncserver, vncserver will ask you to supply a password, this is the password to access your VNC session only, therefore for security purpose, it is recommended not to use the same password as your current login account. The following is the output from a session running at my Ubuntu machine. Output from OpenSolaris will be similar. Observe the output is in the form of [hostname]:[number]. The number identifies your session number, and yes, you can have more than one sessions running at the same time.

    You will require a password to access your desktops.

    Password:
    Verify:

    New 'ubuntu:1 (chai)' desktop is ubuntu:1

    Creating default startup script /home/chai/.vnc/xstartup
    Starting applications specified in /home/chai/.vnc/xstartup
    Log file is /home/chai/.vnc/ubuntu:1.log


  5. To access the VNC sessions at Solaris, from Ubuntu, I use Vinagre, a VNC viewer for GNOME.

  6. The last piece of hurdle we need to clear is on running Gnome desktop under VNC. By default the VNC is configured to run TWM, a fine desktop manager, albeit not as pretty as Gnome. To accomplish this mission, we will edit xstartup under /.vnc (note the period in front of 'v')
  7. Comment out the following line by adding a hash sign (#) in front

    twm &


    The commented out line will look like:

    #twm &


  8. Add the following lines in the xstartup

    unset SESSION_MANAGER
    gnome-session &


    Whenever Gnome (or other session managers like KDE) runs, it will set the variable SESSION_MANAGER, and by default Gnome will not run when another session manager is active. We unset this variable to circumvent the check.
  9. Finally, to end a VNC session:

    vncserver -kill :[session number]

    In our case, the correct command will be

    vncserver -kill :1

2 comments:

The Soothsayer said...

You can use VNC for the same purpose as remote desktop as well. Can't remember the exact advantage of doing that but I know I did it last time. :)

Connect to port 0 of the x server.

Cuppa Chai said...

OpenSolaris's Remote Desktop essentially is an XVNC running at the back, but the disadvantage is it couples the VNC output with the local console output, while regular VNC session will not utilize the local console.