One of the things I like having is a remote system I can access and work on from anywhere. In the past this has meant using either a dedicated server (expensive) or VPS (which is just a VM… too slow).

With Proxmox, I figured I had the option of using a container, which would mean very good performance and not having to dedicate a whole server. However none of the container templates that I could find came with a desktop or VNC out of the box. After much tinkering with different options, I think I finally have found the best solution for getting a running headless VNC server in a Linux container.

This is all written with Proxmox in mind but I believe this should work just fine for LXC and possibly Docker.

If you are using Proxmox, you could skip to the end of this article and take the easy way out…


Once you finish with this guide you should have a working Ubuntu Server Container with XFCE Desktop installed and a working VNC server. This should allow you to remote into the XFCE GUI and use your server as a desktop system.

1. Setup a new container with the Ubuntu 14.04 server template


2. Use the console and update and install XFCE4:

apt-get update && apt-get upgrade && apt-get install xfce4 vim chromium-browser -y --force-yes

That command will take a while, go get some coffee…


3. Add a new user and secure your container by disabling root:

adduser username
adduser username sudo

Make sure you can SSH to the box with the new user and elevate with SUDO. Then

passwd -dl root



4. Install TigerVNC Server:

wget https://bintray.com/artifact/download/tigervnc/stable/ubuntu-14.04LTS/amd64/tigervncserver_1.6.0-3ubuntu1_amd64.deb
sudo dpkg -i tigervncserver_1.6.0-3ubuntu1_amd64.deb
sudo apt-get -f install
sudo dpkg -i tigervncserver_1.6.0-3ubuntu1_amd64.deb

That is repetitive on purpose. Make sure you run the install (you will get an error message), then apt-get -f install, then run the installer again (second time, no error).

Ensure you are logged in as the user account you will be using with VNC…

vncserver :1

That starts the VNC server for your current user account… the :1 means that it is started on port 5901. If you had used :2 then it would be on port 5902, and so on and so forth. It will prompt you to create a password, make it a strong one, it does not have to be the same as your account password. It will also prompt for the creation of a “view only” password, I just said no as I don’t need that.

Then stop the vncserver.

vncserver -kill :1



5. Configure TigerVNC Server VNC Session for your User

All of the above should have created a .vnc directory in your user’s home folder. Next, backup the xstartup file with this command.

cp ~/.vnc/xstartup ~/.vnc/xstartup.bak

This next command will replace the xstartup file with settings appropriate for running XFCE. Copy and paste the whole block below into your terminal and hit enter.

cat > ~/.vnc/xstartup <<EOF
#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
EOF



6. Set VNC to Automatically Start When the System Starts

Next we need to make sure our VNC server session starts every time the server boots. Modify the command below and change “myusername” with the username for your VNC session. Then run the command to write that line to the appropriate file.

sudo su
echo 'VNCSERVERS="1:myusername"' >> /etc/default/vncservers
update-rc.d vncserver defaults

Finally, manually start the VNC server again.

exit    # If you sudo su above then you are root and you need to type "exit" to go back to your user account
vncserver :1

VNC for your container is now good to go!


7. Install TigerVNC Viewer on your home workstation.
Now you need to get the viewer application for your local workstation that will be used to connect to your remote VNC session.

You can download the TigerVNC Viewer App for Windows from here: https://bintray.com/tigervnc/stable/tigervnc/1.6.0

Direct 64-bit Windows Viewer download link: https://bintray.com/artifact/download/tigervnc/stable/vncviewer64-1.6.0.exe

Once that is downloaded, drop the exe file onto your desktop and double-click it.

You might want to adjust some options in the client. For example, I set my remote screen size to 1440×900 and I tick the option to “resize remote session to local window”. On the security tab I would also recommend you untick “none” for the encryption and authentication methods. You should always be running encryption if possible.

Once your options are adjusted, just go to where it says “vnc” server and enter your public IP and port, ex.:

500.506.506.50:5901

Then click “connect”


8. XFCE: No Icons Fix

You will get a prompt from XFCE asking how you want your desktop setup, I chose “default”.

The only annoyance I have found so far is that there are missing icons. This is easily fixed by going to “Applications Menu” in the upper-right-hand corner –> settings –> appearance –> Icons tab –> select Tango –> You now have icon…

We also installed Chromium up top so that is your default browser.


Conclusion:
I am not a huge fan of using a desktop GUI on a Linux server. However I do like the idea of having a desktop for a system I plan on using as a desktop 🙂 and that is what I did this for.

XFCE is very lightweight and it works really well over a VNC connection.

TigerVNC was one of the best working VNC Server/Client pairs I could find and it is very easy to configure. It just works…

I really like ProxMox containers (instead of VMs) but I didn’t find any that had a desktop like this to boot so starting with Ubuntu Server seemed the easiest route to go. So here we are! Have fun!


Or Take the Easy Way Out
If you are wanting to save yourself a bunch of time and work and just want a new blank Ubuntu 14.04 container with all of the above already setup… I am uploading a sanitized backup you can use in proxmox to get going. Cheers!

File: vzdump-lxc-103-ubuntu-14.04-server-VNC-XFCE-joecool-x85kB49AA02oxk5.zip

Username: joecool
Password: x85kB49AA02oxk5
VNC Port: 5901
SSH Port: 22

Usage: Move the zip to your proxmox server and unzip into your backup folder. Should be /somefolderstructure/dump/. If you have backups of other containers they will be stored there. Then in the proxmox webgui you can restore the backup to either a new container number or a pre-existing container. Enjoy!


References:

1 of 1

One comment on: Proxmox – Ubuntu Server 14.04 – TigerVNC – How to Remote Desktop into a Linux Container

  1. Pingback: Stupid Simple VNC — No Really – It’s Easy… use TigerVNC « KiloRoot

Join the discussion

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