Knowledge Base/Using Tier 3/Servers

Steps to Install a Headless GNOME GUI Desktop on Ubuntu Server and Then Remote Control Server Desktop with TightVNC

Dave Burkhardt
posted this on November 09, 2011 10:14

The following instructions provide a detailed step-by-step instructions for Tier 3’s customers who wish to provision a GUI desktop on their Ubuntu servers, and then run a remote desktop application (TightVNC) to control the desktop.
 
Note: Installing any desktop GUI on a Linux server is generally not recommended since these desktop GUI applications can slightly impact the performance of the server. Hence, Tier 3 does not provision Linux GUI desktops by default. Although, administrators who are new to Linux operating systems may find using a desktop GUI (and the associated tools that is installed with the desktop) easier to use than a Linux command line interface.
 
Steps to Install a Headless GNOME GUI Desktop on Ubuntu Server and Then Remote Control Server Desktop with TightVNC:
1. Create an Ubuntu server in Tier 3’s Control Portal (see Quick Start Guide for additional details - http://help.tier3.com/entries/20533612-tier-3-quick-start-guide)
 
2. Establish an OpenVPN tunnel to your Tier 3 servers (see Quick Start Guide for details), and start an SSH client (The instructions below will utilize PuTTY, see the following URL to download: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html)  and enter IP address of server created in Step 1
 
3. Type in the ID and password created in Step 1
 
Note: Linux is case sensitive! Also, for the following steps do not type the [ ] symbols – ONLY the text in-between (unless stated other)
 
4. Type: [apt-get install tightvncserver] and select the enter key.
 
5. Type: [cd /etc/init.d] and select the enter key.
 
6. Type: [nano vncserver] and select the enter key.
 
7. Paste the following text (in bold - including the [ ] symbols) into the window – Tip: Here are the steps to paste text in Nano:
a. Highlight text below in bold and select copy (including the [ ] symbols):
b. Make sure no text exists in the nano vncserver file
c. Right click with your mouse in the PuTTY window and text below should now be listed in the vncserver file
d. Hold down the ctrl key and the x key, select y to save changes, and then enter
#!/bin/sh -e
### BEGIN INIT INFO
# Provides:          vncserver
# Required-Start:    networking
# Default-Start:     3 4 5
# Default-Stop:      0 6
### END INIT INFO
 
PATH="$PATH:/usr/X11R6/bin/"
 
# The Username:Group that will run VNC
export USER="root"
#${RUNAS}
 
# The display that VNC will use
DISPLAY="1"
 
# Color depth (between 8 and 32)
DEPTH="16"
 
# The Desktop geometry to use.
#GEOMETRY="<WIDTH>x<HEIGHT>"
#GEOMETRY="800x600"
GEOMETRY="1024x768"
#GEOMETRY="1280x1024"
 
# The name that the VNC Desktop will have.
NAME="my-vnc-server"
 
OPTIONS="-name ${NAME} -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 "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
 
restart)
$0 stop
$0 start
;;
esac
 
exit 0
 
8. Type: [vncserver] and select the enter key.
 
9. You will be prompted to create a TightVNC server password – type in a password (and also make note of it since you will need it every time you logon to remote control your desktop).
 
10. Type: [chmod 775  vncserver] and select the enter key.
 
11. Type: [update-rc.d vncserver defaults] and select the enter key.
 
12. Type: [cd ~/.vnc] and select the enter key.
 
13. Type: [nano xstartup] and make sure the xstartup file says exactly the text in bold (including the [ ] symbols):
#!/bin/sh
 
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
 
#[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
#[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
#xsetroot -solid grey
#vncconfig -iconic &
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
 
unset SESSION_MANAGER
sh /etc/X11/xinit/xinitrc
 
14. Type: [apt-get update] and select the enter key.
 
15. Install GNOME desktop by typing: [apt-get install ubuntu-desktop] and select the enter key and yes when prompted. Note: This step takes about 15-20 mins to complete.
 
16. Connecting with TightVNC:
a. Install TightVNC on your Windows desktop (see http://sourceforge.net/projects/vnc-tight/)
b. From PuTTY (ensure you are connected to your Linux server still via the OpenVPN client - see steps 2 & 3 above) type: [vncserver] and select the enter key.
c. Take note of the desktop number. In example output below, the desktop number is 2:
“New 'X' desktop is WA1BTDIDJB02:2”
Note: The desktop number coordinates with TCP port number you will configure later
d. Click on top left corner of your PuTTY window and select Change Settings
e. Chose SSH and then Tunnels
f. Type 5902 for the source port (note: if you received another number than 2 you will need to replace the 2 in the number 5902 – e.g., desktop number 5 would be 5905. Also, you would use this 5905 in the following steps as well if you received desktop number 5)
g. At Destination type: localhost:5902
h. Select Add, and then Apply
i. Start TightVNC and type: [localhost:5902]
j. Select Connect, and type in the password you created in Step 9
k. You now should now be able to remote control a GNOME desktop
 
Repeat steps b-k every time you need to reconnect to your GNOME desktop.

Important Note: It is not recommended as a Linux administration best practice to utilize root, and individual user accounts should be provisioned when accessing/managing a systems. The instructions above were written in the simplest terms in mind, hence why steps instructed to utilize the "root" users account.  The steps below provide instructions for creating a user account, and then how to access the aforementioned GNOME GUI via TightVNC:
1. Follow steps b-k to render a GNOME desktop
2. Select System, Administration, and then Users and Groups from the GNOME desktop
3. Type in a user name and select Ok
4. Create a password and chose Ok
5. If you want the user to be an administrator of the system, select "change", click "Administrator", and then Ok
6. Close TightVNC and and then within the SSH/PuTTY session type [logout] and enter
7. Start a new PuTTY session and connect to your Linux server using the credentials you created in the 3 & 4, and then type: [vncserver] and select the enter key.
8. You will be asked to create a vncserver password for your new user
9. Follow steps c-k above

 
Topic is closed for comments