Ubuntu 14.04 Amazon EC2 Cloud Desktop using LXQT
By Leo Gaggl
Using Amazon EC2’s free usage tier to host your own cloud desktop is a very economical way to to have a desktop at hand anytime you can not be near one. Since I quite often use Chromebooks these days when on the road this is a particular handy way should I need a full desktop for certain tasks.
Since Ubuntu 14.05 is my default desktop on my normal hardware I obviously want to have my cloud desktop running the same underlying OS. However I don’t think running Unity as the desktop interface would be appropriate via a low-bandwidth remote desktop connection. For this reason I chose LXQT. If you need total stability you probably should go for the more mature LXDE instead, but I have already tried LXQT on an old EEE PC and was very impressed by the speed and low resource usage.
NOTE (Edit: 2014-11-03): Please find an updated (and easier) version of this blog here. I was experiencing some issues with LXQT (which is understandable as it clearly states that it is not a release version)
Provision Ubuntu 14.04 LTS EC2 Instance
Instance details
- Connect to AWS Console and go to EC2 Service
- Choose OS Image: “Ubuntu Server 14.04 LTS” (see screenshot)
- Choose a “Micro Instance” if you want to use Amazon’s Free Usage Tier
- Choose Instance details – the defaults will generally be fine
- Add Storage (I generally add a separate Volume for /home but default should do)
- Tag instance (just give it a name to that makes sense to you in the console if you have more than one)
- Configure Security Group – I only set SSH which is the default (see Firewall config below). Add any other ports needed
- Review & Launch the instance. You need to choose your RSA Access Keys in this step. If you haven’t got any and download. DO NOT LOOSE the private keys or you will not be able to connect.
Setup Desktop & VNC
Connect via SSH to the EC2 Instance you just created (using the IP in the control panel and your RSA Key)
sudo apt-get install software-properties-common<br></br>sudo add-apt-repository ppa:lubuntu-dev/lubuntu-daily<br></br>sudo add-apt-repository ppa:gilir/q-project<br></br>sudo apt-get update<br></br>sudo apt-get upgrade<br></br>sudo apt-get install lxqt-metapackage lxqt-panel vnc4server
Start VNC server under the desired user account. This will create the desired configuration files. Kill after the startup process is finished.
vncserver<br></br>#after successful start<br></br>vncserver -kill :1
Edit xstartup files
vim ~/.vnc/xstartup
Paste the following:
#!/bin/sh<br></br># Uncomment the following two lines for normal desktop:<br></br>unset SESSION_MANAGER<br></br>#exec /etc/X11/xinit/xinitrc<br></br>exec openbox-session &<br></br>startlxqt &<br></br>[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup<br></br>[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources<br></br>xsetroot -solid grey<br></br>vncconfig -iconic &<br></br>#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &<br></br>#x-window-manager &
Create startup script
sudo vim /etc/init.d/vncserver
Paste the following:
#!/bin/bash<br></br>### BEGIN INIT INFO<br></br># Provides: vncserver<br></br># Required-Start: $syslog<br></br># Required-Stop: $syslog<br></br># Default-Start: 2 3 4 5<br></br># Default-Stop: 0 1 6<br></br># Short-Description: VNC Server Startup Script<br></br># Description: Author: Leo Gaggl (www.gaggl.com)<br></br>### END INIT INFO<br></br>unset VNCSERVERARGS<br></br>VNCSERVERS=""<br></br>[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf<br></br>prog=$"VNC server"<br></br>start() {<br></br>. /lib/lsb/init-functions<br></br>REQ_USER=$2<br></br>echo -n $"Starting $prog: "<br></br>ulimit -S -c 0 >/dev/null 2>&1<br></br>RETVAL=0<br></br>for display in ${VNCSERVERS}<br></br>do<br></br>export USER="${display##*:}"<br></br>if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then<br></br>echo -n "${display} "<br></br>unset BASH_ENV ENV<br></br>DISP="${display%%:*}"<br></br>export VNCUSERARGS="${VNCSERVERARGS[${DISP}]}"<br></br>su ${USER} -c "cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}"<br></br>fi<br></br>done<br></br>}<br></br>stop() {<br></br>. /lib/lsb/init-functions<br></br>REQ_USER=$2<br></br>echo -n $"Shutting down VNCServer: "<br></br>for display in ${VNCSERVERS}<br></br>do<br></br>export USER="${display##*:}"<br></br>if test -z "${REQ_USER}" -o "${REQ_USER}" == ${USER} ; then<br></br>echo -n "${display} "<br></br>unset BASH_ENV ENV<br></br>export USER="${display##*:}"<br></br>su ${USER} -c "vncserver -kill :${display%%:*}" >/dev/null 2>&1<br></br>fi<br></br>done<br></br>echo -e "\n"<br></br>echo "VNCServer Stopped"<br></br>}<br></br>case "$1" in<br></br>start)<br></br>start $@<br></br>;;<br></br>stop)<br></br>stop $@<br></br>;;<br></br>restart|reload)<br></br>stop $@<br></br>sleep 3<br></br>start $@<br></br>;;<br></br>condrestart)<br></br>if [ -f /var/lock/subsys/vncserver ]; then<br></br>stop $@<br></br>sleep 3<br></br>start $@<br></br>fi<br></br>;;<br></br>status)<br></br>status Xvnc<br></br>;;<br></br>*)<br></br>echo $"Usage: $0 {start|stop|restart|condrestart|status}"<br></br>exit 1<br></br>esac
Mark the startup script as executable and create the config file for the startup script.
sudo chmod +x /etc/init.d/vncserver<br></br>sudo mkdir /etc/vncserver<br></br>sudo vim /etc/vncserver/vncservers.conf
Paste the following:
VNCSERVERS="1:USERNAME"<br></br>VNCSERVERARGS[1]="-geometry 1024x768"
update-rc.d vncserver defaults 99
Start the VNC Server
sudo /etc/init.d/vncserver start
Firewall configuration
By default VNC will use port 9501 (and subsequent ports for each session). Since VNC password authentication is generally very weak I personally do not expose this port through the firewall. I use SSH port forwarding to tunnel the VNC port through SSH (encrypted) which means only the SSH port is open and can be properly secured.
ssh -L 5901:localhost:5901 -i /path/to/your/aws/keyfile.pem YOUR.EC2.IP.ADDRESS
You should then be able to access VNC via localhost:
Hopefully you should see the LXQT Desktop:
If you want to access this from a Chromebook this blog might help.