Remote Desktop on a Linux Machine: Installing and Configuring VNC and Remmina


Typically you can do everything on a Linux server via the command line, so there is no need for a GUI. However, I ran across an instance where I wanted to run a point-and-click installation wizard, and had the rare occasion to need a GUI. Tutorials on getting a GUI set up were either old, incomplete, or assumed a stronger Linux background than what I had. The best tutorial I ran across was on DigitalOcean: How to Install and Configure VNC on Ubuntu 14.04. Step 1 of my post closely follows that tutorial with a few edits, but with a more end to end view.  Here is the structure:

  • Step 0:  Optional section if you want to spin up a Linux Container to test this idea before running it on your actual server.
  • Step 1:  Closely mirrors the DO tutorial, with a couple minor edits.  Refer to that post if you want more context on what each command is doing.
  • Step 2:  Other posts I found got a little hand wavy on the client side, so this tutorial provides a prescriptive configuration that I was able to get working.  This is also where I had the most difficultly finding good documentation or examples.

A more technical title for this post might be: Installing and configuring VNC server on a fresh Ubuntu 14.04 Linux Container and configuring the Remmina Remote Desktop Client.

<technical parenting> Before moving ahead with this tutorial, I recommend checking your motivations for wanting a desktop environment in the first place. If you are just doing it for file manipulation, then you're not doing yourself any favors. Learn bash. </technical parenting>

(Optional) Step 0: Create a Linux Container

If you already have a Linux machine in mind that you want to connect to, then skip this section and go to Step 1. Otherwise, follow my path of installing a Linux Container, which is a quick, lightweight way to bring up a virtual machine, play around with it and destroy it when you're done. I use them as a clean environment on my Ubuntu laptop to test an idea before deploying it a server that I'm paying for. The commands in Step 0 start from your local machine and end on the remote server.

Install LXC

Assuming your working from a Debian/Ubuntu machine that you want to spin up the Linux Container on, install LXC:

Create an Ubuntu, Trusty, 64bit machine with the hostname of vnc-example. This takes a few minutes on your first run, but it caches for each subsequent machine you create to speed things up to just a couple of seconds.

Now start the vnc-example machine, which is analogous to booting it up but it's nearly instant.

Check the status to see that it's running and make note of the IP address, we'll need that later.

Connect into the machine with console access, similar to SSH, even though SSH isn't installed on our box yet.

Now you are in the LXC machine. This is a barebones machine, so install a few tools that we'll need later: SSH and Nano.

Step 1:  Install and Configure VNC

All of these commands are on the remote machine, the machine that you want to connect to. This section roughly follows the DigitalOcean tutorial I mentioned earlier.

Create a user used for connecting into the server via VNC, which I'll call vncuser. The first line adds the user, and the second grants the user sudo privileges.

Switch to our newly created user, vncuser.

Install the packages needed for VNC and patiently wait for a few minutes.

Configure VNC by running this command that will ask for VNC password. I opted not to do the view only option.  Note this is the second password we're setting up, one for the vncuser on the linux box, and now a VNC password.

You'll notice in the output that the last step also started the vncserver, which we need to kill for now because further configuration is needed.  Stop the service:

Now replace the contents of xstartup file with everything the DO tutorial recommends.  If you're not strongly opinionated on an editor, try using Nano like in this example.

Replace everything in the xstartup file with this:

Make the file we just edited executable.

Continuing with the configuration, create a vncserver file in the /etc/init.d/ folder.

Edit the file we just created, replacing the contents with everything that DO recommends.  There is one exception, since we'll add our vncuser to this file.

Assuming you are using vncuser like I am, you can copy paste this exact text into the vncserver file.

Make the vncserver file executable.

Start the VNC server service.

As a final step on the remote server side, make note of the IP address.

Step 2:  Using Remmina to Connect

You're done on the remote linux server side, the rest of this post applies to your local machine that you will be connecting from.

There are many VNC clients that you could use, I found that Remmina worked well. Install Remmina from the command line with:

Now we'll set up port forwarding on your local machine. Important - this is run locally, not on the remote server. For this step, you'll need the username, which is vncuser and the IP address of for the remote server in my case. Replace the last two arguments with your username and remote server IP.  Say "yes" when it prompts whether you want to adds this host to the list of trusted locations.  You'll be prompted for the password that we set on the remote server at this step.

The rest is point and click, and where I had the hardest time, hence my motivation to extend the DO tutorial.

Open up Remmina Remote Desktop Client Application. Click the second icon to "Create a new remote desktop file." Populate the fields as follows:

  • Name:  whatever you like
  • Protocol:  VNC - Virtual Network Computing
  • Basic - Server:  localhost:5901
  • Basic - Username:  vncuser
  • SSH - Enable SSH Tunnel:  checked
  • SSH - Tunnel via loopback address:  checked
  • SSH - SSH Server - Custom:  your remote server's IP
  • SSH - SSH Authentication - Username:  vncuser
  • SSH - SSH Authentication - Password:  checked

Here is what my set up looks like:

Remmina Config 1 Remmina Config 2

Once you hit connect, your desktop should look like this:

Remmina - Connected

The default browser didn't work for me, so I installed Firefox with the following. You'll find it through the button on the top left, Applications Menu > Internet > Firefox Web Browser

Now that you've gotten this far, resist the urge to use it.

Posted in linux.

Leave a Reply

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