LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Is It Possible to Use Your VPS as a Virtual Workspace?

Converting your virtual private server into a fully functional virtual workspace can be achieved under the right circumstances. The general idea behind converting Linux into a virtual workspace is to perform the following two steps:

  1. Install and Configure the GUI
  2. Install and Connect to your VPS with VNC

The Basics of Installing a GUI

You have a couple options as far as installing a GUI for your VPS.

Let’s assume you have Ubuntu. You will want to ensure that you have the necessary resources available on your system to perform this install.

To install the full fledged Unity desktop, open your command line and type:

> sudo apt-get install ubuntu-desktop

Since this VPS is likely a low end box, you probably won’t need the extra features that come with the full fledged desktop.

To install the GUI without bloatware such as Libre Office and others, so you might want to install a lighter version of Unity desktop using the following command:

> sudo apt-get install –no-install-recommends ubuntu-desktop

The Basics of Installing a VNC on your VPS

Now that your desktop environment is installed, lets focus on how to gain access to your new virtual workspace.

Virtual Network Computing, better known as VNC, is a connection protocol that gives a remote operator the ability to send keystrokes and mouse clicks over a network connection allowing the user to interface with a graphical desktop environment on the remote server.

In order to install VNC, simply type the following commands:

> sudo apt-get update

> sudo apt-get install tightvncserver

To complete the VNC server’s initial configuration, use the vncserver command to set up a secure password:

> vncserver

The vncserver command completes the installation of VNC by creating default configuration files and connection information for your VPS to use.

Configuring VNC on your VPS

We must tell our VNC server what commands to perform when it starts up.

These commands are located in a configuration file called xstartup. We will first need to stop the VNC server instance that is running on port 5901:

> vncserver -kill :1

Let’s now back up the original in case we need it later:

> mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

Now we can open a new xstartup file with nano or vim and insert these commands into the file so that they are performed automatically whenever you start or restart your VNC server:

#!/bin/sh

export XKL_XMODMAP_DISABLE=1

unset SESSION_MANAGER

unset DBUS_SESSION_BUS_ADDRESS

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup

[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey

vncconfig -iconic &

gnome-panel &

gnome-settings-daemon &

metacity &

nautilus &

gnome-terminal &

gnome-panel &

gnome-session &

To ensure that the VNC server will be able to use this new startup file properly, we’ll need to grant executable privileges to it:

> sudo chmod +x ~/.vnc/xstartup

To easily control our new VNC server, we should set it up as an Ubuntu service. Open a new service file in /etc/init.d with nano or vim:

> sudo nano /etc/init.d/vncserver

The first block of data will be where we declare some common settings that VNC will be referring to a lot, like our username and the display resolution.

#!/bin/bash

PATH=”$PATH:/usr/bin/”

export USER=”your-user”

DISPLAY=”1″

DEPTH=”16″

GEOMETRY=”1024×768″

OPTIONS=”-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY}”

. /lib/lsb/init-functions

case “$1” in

start)

log_action_begin_msg “Starting vncserver for user ‘${USER}’ on localhost:${DISPLAY}”

su ${USER} -c “/usr/bin/vncserver ${OPTIONS}”

;;

stop)

log_action_begin_msg “Stopping vncserver for user ‘${USER}’ on localhost:${DISPLAY}”

su ${USER} -c “/usr/bin/vncserver -kill :${DISPLAY}”

;;

restart)

$0 stop

$0 start

;;

esac

exit 0

Make this service script executable, so that you can use the commands that you just set up:

> sudo chmod +x /etc/init.d/vncserver

Now can start your VNC server instance with the following command:

> sudo service vncserver start

Don’t forget to add the new service on your startup using the following command:

> sudo update-rc.d vncserver defaults

Now you will be able to connect to your remote server using any VNC client. In case you have a firewall installed on your VPS, make you poke a hole in the configuration to have port 5901 open.

10 Comments

  1. VNC will be slow as hell. Make a guide for RDP. :P

    August 27, 2016 @ 12:30 am | Reply
  2. Tamwyn:

    As many of the offered boxes on this site are openVZ based, I’d like to know whether these containers could actually run a desktop environment and if not, it might be worth mentioning. Generally some onformations about performance might be interesting.

    Another thought may be the consideration of the usage of an ssh proxy, with the benefit of not having a vnc running open on the internet.

    August 27, 2016 @ 1:47 am | Reply
  3. ACF:

    If we’re talking about a VPS there’s every chance there won’t be much performance behind it. I for one use them as test beds before deploying to a dedicated server. This guide here is basic and easy, and it’ll cover the installation of a lightweight GUI on Ubuntu/Debian: https://vpsboard.com/topic/2786-running-a-lightweight-gui-on-your-vps/

    August 27, 2016 @ 7:58 am | Reply
  4. r137:

    rdp on linux :O ??

    August 27, 2016 @ 10:01 am | Reply
  5. martin:

    NoMachine NX is much better than VNC.

    https://www.nomachine.com/download/

    August 27, 2016 @ 3:09 pm | Reply
  6. Maounique:

    For debian, what i use for RDP: apt-get install xfce4 xrdp iceweasel mc for a basic desktop. 512 MB and one vcpu is good enough for ovz if not oversold like hell. If you want heavy stuff like flash or play movies, will be slow as hell, no matter how you tweak the compression, but will work good enough to get the idea.

    August 30, 2016 @ 9:44 am | Reply
  7. i like vnc but can’t copy from destop to server.
    but keep use that beacause low price hihihi

    August 30, 2016 @ 2:29 pm | Reply
  8. Mavromatis Lozay:

    Nice idea, I’m using C9.io for a similiar effect, but only for text based.

    September 19, 2016 @ 5:56 pm | Reply
  9. Cheapwebdev:

    VNC part fails for Ubuntu 16.04…

    November 19, 2016 @ 9:33 pm | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *