Showing posts with label Desktop Environment. Show all posts
Desktop environment for Ubuntu 14.04 server This guide will tell you how to setup Desktop environment and a VNC server on an Ubuntu 14.04 server. The server will use a fast lightweight remote service – TightVNC package. After this, the next tutorial will explain how to connect to the server remotely and securely through SSH tunnel.
Prerequisites
  • Ubuntu 14.04 Server
  • Root Privilege

How to Install Desktop Environment and VNC server

First we have to get XFCE, TightVNC Packages. Do the following:
sudo apt-get update
sudo apt-get install xfce4 xfce4-goodies tightvncserver
In this tutorial, we will use demo as user. To add new user, do the following:
adduser demo
Giving permission to demo user:
visudo
Find the line # User privilege specification
Below the line root ALL=(ALL:ALL) ALL , paste the following line:
demo    ALL=(ALL:ALL) ALL
Save the changes by pressing ctrl+o and exit ctrl+x

Login to your user account that will be used to connect remotely.
su demo
Set VNC password
vncserver

Lets start configuring the VNC Server

vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak
nano ~/.vnc/xstartup
Insert this code:
#!/bin/bash
xrdb $HOME/.Xresources
startxfce4 &
Save it by pressing ctrl+o, then exit ctrl+x

Grant executable privilege:
sudo chmod +x ~/.vnc/xstartup
Create a VNC service file
sudo nano /etc/init.d/vncserver
Paste the following code. If you are using different user, please change the line 3.
#!/bin/bash
PATH="$PATH:/usr/bin/"
export USER="demo"
DISPLAY="1"
DEPTH="16"
GEOMETRY="1024x768"
OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
. /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
Save it by pressing ctrl+o, then exit ctrl+x

Now make this code executable:
sudo chmod +x /etc/init.d/vncserver
sudo service vncserver start
Every time you restart your server, you have to run sudo service vncserver start

Some may wish to always do this manually just to save server memory. You can start the vnc service only when needed.

But if you wish to run the service automatically, the step is mentioned in the next tutorial: Remote Ubuntu Desktop Environment using VNC Client

In the next tutorial, we will explain how to connect to the server remotely and securely through SSH tunnel.

Remote Ubuntu Desktop Environment using VNC Client through SSH tunnel. In this tutorial , you will learn how to remote your Ubuntu Desktop Environment using VNC Client through SSH tunnel. This is a continuation of the earlier post about setting up Desktop Environment for Ubuntu 14.04

This tutorial uses Windows computer. As the continuation of this tutorial, we will use demo username to login remotely to our server.
Prerequisite:
  • Putty software
  • VNC Client software

Setup your putty connection

We need to create SSH connection on your local computer

1. On Putty under host name, type the server ip address or domain name
2. Under Saved Sessions, type the name of this connection (any name, its up to you)
3. On the left panel, you see Category. Go to Connection >> Data >> Auto-login username >> type your username (demo)
4. On Connection >> SSH >> Tunnels>> Enter the following details


A. Source Port: 5901
B. Destination: localhost:5901
C. Click Add button
After adding this setting, you should see this on the listbox:
L5901 localhost:5901
Don’t click Open button yet or you’ll loose your setting.
5. On Category >> Session. On the right, click Save button
6. Then click Open to start the connection connect.
7. Login to your server by typing your password

Remote your Ubuntu 14.04 Server

Open your VNC client software. On VNC server text box, type localhost:5901


Click Connect button and enter your VNC Password
If you see below image, Congratulation!!! You just connected to your server.




In the previous tutorial, we mentioned every time we restart the server we should run sudo service vncserver start. This may give you an option to run the service only when needed just to save memory.
But if you wish to run the service automatically run the following code on your server console:
sudo update-rc.d vncserver defaults

Copyright © 2012 My Linux Code