×

How to Get Desktop View of Ubuntu 14.04 Server in Compute Engine?

How to Get Desktop View of Ubuntu 14.04 Server in Compute Engine?

How to Get Desktop View of Ubuntu 14.04 Server in Compute Engine?
  • Create a VM instance with Ubuntu 14.04 server

  • Connect to your instance either through SSH option or use gcloud option. Once connected update the source list.

              $ sudo apt-get update

  • Then we need to install the Gnome components for our virtual desktop. So type the following command:

             $ sudo apt-get install gnome-core

           when prompted type Y and then press [Enter]

  • Start the vnc server, You’ll then be prompted to create and verify a new password:

$ vncserver

  • If everything went fine your VNC server is now running and listening on port 5901. You can verify this with netcat from the Google Compute Engine instance:

$ nc localhost 5901

RFB 003.008

  • We now need to kill the session we just created and make a tweak to the startup script for VNCServer to make it work properly. If we don’t perform this step then all we will see is a grey cross-hatched screen with an “X” cursor and/or a grey screen with a Terminal Session, depending on the Ubuntu version. Not very useful!

  • So, type the following command to kill the session:

$ vncserver -kill :1

  • Now open the file we need to edit:

$ sudo nano .vnc/xstartup


  • Press the [Insert] key (“i” in Ubuntu) once (this will switch us into “edit” mode) and then edit the script so it ends up looking like this:


  • So, we’ve unmasked the unset SESSION_MANAGER line and masked out all the rest. We’ve then added the last 3 lines.When you’re done editing the .vnc/xstartup file for your particular version of Ubuntu press the [Esc] key once and save.

  • Now install a VNC client on your local machine. There are many options available ( TightVNC, RealVNC etc. ). Install any one.

  • Open the firewall

  • First step is to tag our instance as a vnc-server, for that go to the VM description page and click on “add tags”

  • In order to communicate with our instance we need its external IP. You can find it on the Developers Console.

  • Let’s try to connect to it using netcat again:

$ nc (ephemeral IP of instance) 5901

  • We’re going to add a new firewall rule, pressing the corresponding button.

  • First, start the vncserver again on the VM by:

$ vncserver

  • Now make sure that the connection is now allowed by the firewall:

$ nc (ephemeral IP of instance) 5901

RFB 003.008

  • Now open the VNC Viewer, click on File and add a new connection, provide the VNC Server, Name and click on OK



  • Provide the password and click





Trendy