How to enable GUI in VPS

Posted on

Either you have unmanaged Ubuntu or Cent OS server, it comes with no graphical user interface. If you have no experiences before using Unix command system, you will have trouble and need some time to figure it out. You can enable GUI for your VPS with the help of some free tools, such as X2Go, TightVNC. I will guide you with several method that you can be applied yourself.

Ok, let’s begin.

Method 1 Using X2Go

X2Go is lightweight remote desktop solution enables you to access a graphical desktop of a computer over a low bandwidth (or high bandwidth) connection.

Quick howto to turn your machine into an X2Go server:

sudo apt-add-repository ppa:x2go/stablesudo apt-get updatesudo apt-get install x2goserver x2goserver-xsessionsudo apt-get install x2gomatebindings  # if you use MATE/mubuntusudo apt-get install x2golxdebindings  # if you use LXDE/lubuntusudo apt-get install xfce4  # if you use Xfce

I recommend you using xfce4 as I do. Or you can install any desktop environment as you like.

Quick howto to install the x2goclient:

Windows

Grab the latest X2Go client and run the executable binary with Administrator right.

https://code.x2go.org/releases/binary-win32/x2goclient/releases/4.1.2.0-2018.06.22/

Ubuntu/Debian

X2Go Client is part of Ubuntu 12.04 & later, as well as Debian Wheezy & Jessie. Install it using the software center or by following command:

sudo apt-add-repository ppa:x2go/stablesudo apt-get updatesudo apt-get install x2goclient

OSX

Download the appropriate disk image from Download X2Go for OS X™.

If there are multiple options, choose the one closest to your current operating system’s version number. Do not try to use a build that is targeted at a higher OS X version number then you currently have.

Afterwards, open the disk image and “install” x2goclient.app as you would any other App Bundle by dragging it into /Applications/.

Run X2Go Client

Run X2Go client depend on your system as guided above.

Install Application

In example we want to install Google Chrome browser, you need to do following steps.

sudo nano /etc/apt/sources.list.d/google-chrome.list

Append with this list

deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main

Save it. And download and add its signing key.

wget https://dl.google.com/linux/linux_signing_key.pub  | sudo apt-key add -

Update your sources.

sudo apt-get update 

Then, install Google Chrome with this command.

sudo apt-get install google-chrome-stable

Or you can grab following bash script to install it.

#!/bin/bashif [ ! $(id -u) = 0 ]; then   echo "you are not root"   echo "run this script with 'sudo'"   exitfiecho "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >  /etc/apt/sources.list.d/google-chrome.listwget https://dl.google.com/linux/linux_signing_key.pubapt-key add linux_signing_key.pubapt updateapt install google-chrome-stable

Navigate to Applications > Internet > Google Chrome. Now you can browse as usual.

Navigate to Applications > Internet > Google Chrome

How to keep session when leave vnc client

If you still have work to do and you have other urgent matter and you need to leave your work, you can keep the X2Go session and close x2Go client or shutdown your PC/laptop. You can do with these simple steps.

In your server, navigate to cli command and do followings:

This command will open a session and keep it alive.

x2godesktopsharing on :0

In your X2Go Client, you can connect to session that already open. Change your connection to local desktop.

Change connection to local desktop

You will get any session that you made before. Choose that session, then you can resume your previous work.

Resume existing session

Method 2 Using TigerVNC

TigerVNC is a high-performance, platform-neutral implementation of VNC (Virtual Network Computing), a client/server application that allows users to launch and interact with graphical applications on remote machines. TigerVNC provides the levels of performance necessary to run 3D and video applications, and it attempts to maintain a common look and feel and re-use components, where possible, across the various platforms that it supports. TigerVNC also provides extensions for advanced authentication methods and TLS encryption.

Quick howto to install TigerVNC Server:

sudo apt install tigervnc-standalone-server tigervnc-xorg-extension tigervnc-viewersudo apt install kfce4 # if you want kfce desktop environment

Quick howto to configure vnc service:

First, you need to set your VNC password. Make sure you make a password and remember or keep it in a safe place. It will be needed to login to VNC in a client. The password must be minimal 7 characters or more.

vncpasswd

Quick howto to configure xfce4 as desktop environment:

You need to create a filename ~/.vnc/xstartup and append below bash script.

#!/bin/sh# Start xfce4 Desktop[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresourcesvncconfig -iconic &dbus-launch --exit-with-session xfce4-session &

Now, you can start VNC desktop using vncserver command. Please refer following syntax to use it.

vncserver [:display#] [−name desktop-name] [−geometry widthxheight] [−depth depth] [−pixelformat format] [−fp font-path] [−fg] [−autokill] [−noxstartup] [−xstartup script] [Xvnc-options...]vncserver −kill :display#vncserver −list

Quick howto to create VNC desktop server:

We will create VNC desktop session.

# vncserver :1 -geometry 1024x768 -depth 16 -pixelformat rgb565

New 'vmi289520.contaboserver.net:1 (root)' desktop at :1 on machine vmi289520.contaboserver.netStarting applications specified in /etc/X11/Xvnc-sessionLog file is /root/.vnc/vmi223520.contaboserver.net:1.logUse xtigervncviewer -SecurityTypes VncAuth -passwd /root/.vnc/passwd :1 to connect to the VNC server.

To verify service running:

# pgrep Xtigervnc# ss -tulpn | egrep -i 'vnc|590'

To list already created session:

# vncserver -listTigerVNC server sessions:X DISPLAY #     PROCESS ID:1              20498

Now, you are ready to view it in your VNC viewer. All VNC request will be use port prefix port number 590x. The last number refer to desktop session number you create in server. In the example above desktop display number 1 (:1), so you will put remote host server with port 5901. If you want to start another session (:2) you will need port 5902 to connect.

Quick howto to view vnc session using VNC Client:

You need to download TightVNC Java Viewer.  The latest version is 2.8.3. Extract and run tightvnc-jviewer.jar (suppose you already installed java sdk/jre). You will get vnc viewer as following.

Using TightVNC viewer to connect to TigerVNC session

  • Remote Host: fill with localhost or 127.0.0.1 because you will be connected using SSH tunneling
  • Port: your TigerVNC session desktop number (i.e: :2 fill it with 5902)
  • User SSH tunneling: Check it.
  • SSH Server: your server ip
  • SSH Port: SSH port (default 22)
  • SSH User: your ssh username

After that hit connect. You will then need to fill ssh password and VNC password that already define before in above tutorial.

Summary

You will have a remote tool via GUI to manage your server easily, secure and free. If you any question don’t hesitate to leave a comment below. Enjoy !

Loading...

Leave a Reply

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