Remote Desktop to Ubuntu Instance with no GUI.
Once in a while even for Linux/Ubuntu servers you might want remote desktop access. Yeah, you heard right! It is graphical user interface access to the operating system. It is true that we can do anything with Linux/Ubuntu operating systems with full privileged shell access. However, there can be some software applications that at some point of time might need actual GUI interactions to proceed. If you are at such a situation this blog post is for you.
Recently as per the instructions of team lead had to install ‘Wolfram Mathematica 11.3.0’ in one of our Ubuntu 16.04 instances at Google Cloud. After installation to license activation had no other choice than figuring out a way to get remote desktop access so that can proceed with license activation process. Actually it was simple two step procedure;
- Install and configure Teamviewer accepting license and adding a password.
- Create a dummy graphic card (Xorg) configuration and restart the instance.
Alright then, let’s go step by step and see how the above can be done in detail. On a side note, should mention that at the time of writing the latest teamviewer version is 13. Teamviewer is free for personal use and please purchase a license if you are gonna utilize it for commercial purposes. Purchasing a license ensures teamviewer will be available for years to come.
Installing teamviewer in Ubuntu 16.04 via remote shell
I found this nice blog post that explain the steps in installing teamviewer via ssh. It was written in 2015. Even though the blog post is bit old for someone who is familiar with linux/ubuntu can figure out how to do it. However, for clarity purpose I will be listing the steps for clarity purposes.
Download the latest teamviewer
Go to https://download.teamviewer.com/download and select the compatible teamviewer for your system. Use wget to download the selected teamviewer package.
$ wget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb
Install prerequisites
$ sudo apt-get update$ sudo apt-get install ubuntu-desktop -y$ sudo apt-get install gdebi -y
Install teamviewer
Go into the directory into where you downloaded the teamviwer and install it as follows.
$ sudo gdebi teamviewer_amd64.deb
Configuring teamviewer
After successful installation of the teamviewer the next step is to configure the installed teamviwer. To get the information about the possible commands of teamviewer just use the following command. If you are smart enough you can figure out all with those information.
$ teamviewer help
However, I’ll be explaining the bare minimum configuration you need to know to get remote desktop working. First you need to configure a password for the teamviewer. This password is should be used in remote access from another computer. Then should enable teamviewer such that it get started whenever system restarts. Finally should accept the license agreement of teamviewer.
$ #set up teamviewer's password
$ sudo teamviewer passwd password946
$ #make teamviewer start at boot and start if it is not currently running
$ sudo teamviewer daemon enable$ # accepting license agreement of teamviwer
$ sudo teamviewer license accept
Once all done what you need is to know the teamviewer Id that should be used when connecting from another machine. Teamviewer Id can be found by issuing the following command.
$ teamviewer info
Creating a dummy graphic card (Xorg) configuration
Even though teamviewer installation is done, still you’ll be not able to get remote desktop access because to teamviewer to run it needs a graphic interface configuration. If there is no actual graphic adapter, then we can create a dummy graphic configuration and make teamviewer work fine. That’s what exactly we are going to do here.
In this article it explains how to create a dummy graphic interface configuration of debian operating systems. For Ubuntu what we need to do is create a dummy xorg.conf file as follows.
Install prerequisites
$ sudo apt-get install xserver-xorg-video-dummy
Create xorg.conf
Create a xorg.conf file inside /etc/Xorg/ with the following content. To be in the safe side, if xorg.conf file already exist inside /etc/Xorg/ then back it up first.
# This xorg configuration file is meant to be used
# to start a dummy X11 server.
# For details, please see:
# https://www.xpra.org/xorg.conf
# Here we setup a Virtual Display of 1600x900 pixels
Section "Device"
Identifier "Configured Video Device"
Driver "dummy"
#VideoRam 4096000
#VideoRam 256000
VideoRam 16384
EndSection
Section "Monitor"
Identifier "Configured Monitor"
HorizSync 5.0 - 1000.0
VertRefresh 5.0 - 200.0
Modeline "1600x900" 33.92 1600 1632 1760 1792 900 921 924 946
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
SubSection "Display"
Viewport 0 0
Depth 24
Virtual 1600 900
EndSubSection
EndSection
Tada.. Now you are all set. But before you try to connect via teamviewer you should restart the remote instance to graphic configuration to take effect.