When graphical desktops are not installed on an Ubuntu server, graphical user interfaces are sometimes necessary and must be forwarded and displayed on client machines. Some of the reasons for example :
- Complex graphical setups (Oracle…), preferred way compared to console mode and/or silent installations.
- Running Android studio on a more powerful server when the client machine does not meet the hardware requirements (memory, CPU…) to install it.
Obviously, when implementing this feature, the bandwidth between the server and the client must be sized accordingly (optical fiber…).
Few easy steps are required on Ubuntu 18.04 and Windows 10 client to perform this mechanism.
Three packages must be first installed :
- xvfb : X Virtual Frame Buffer
- xdm : X Desktop Manager
- xfonts-base : Base fonts
As root, with only one command line on Ubuntu :
root@vps:~% apt-get install xvfb xdm xfonts-base
Then, still as root, the following packages are installed :
- xterm (X Terminal)
- twm (Tab Window Manager)
- xfonts-100dpi* : bitmapped fonts (100 dots per inch)
root@vps:~% apt-get install twm xfonts-100dpi* xterm
Set the parameter
yes in the SSH daemon configuration file
… X11Forwarding yes …
Then restart the daemon sshd if this parameter was set to
root@vps:~$ service ssh restart
Configuring X Servers
X Server is then configured to use xvfb (X Virtual Frame Buffer) instead of the X default engine.
In the file
/etc/X11/xdm/Xservers, replace the line below
:0 local /usr/X11R6/bin/X vt7 -dpi 100 -nolisten tcp
:0 local /usr/X11R6/bin/Xvfb -dpi 100 -screen 1024x768x16
Then, as root, restart the X Destop Manager daemon
root@vps:/etc/X11/xdm:~$ service xdm restart
[ ok ] Restarting xdm (via systemctl): xdm.service.
Install XMing Server for Windows (Download page : XMing 126.96.36.199 for Windows ). Select a full installation.
Xming Server must be allowed in the windows firewall Windows Defender.
This is an old 32 bits version (2007), but still fully operational on Windows 10 64 bits recent versions. Newer versions, especially the 64 bits version, are available but unfortunately a donation is mandatory (10 £ minimum), however alternatives exist in case of failures for any reason (for example : VcXsrv).
When the Windows XMing server is running on the client, an icon XMing appears in the windows system tray. Viewing log file and shutdown options are available with a right click on this XMing icon.
By default, the command line running the XMing server is (see log file) :
D:\software\tools\xming\Xming.exe :0 -clipboard -multiwindow
If XMing Server is not running, start it from the programs menu :
XMing Server is listening by default on port 6000. To find XMing Server process ID, in a DOS command line (run as administrator) :
C:\> netstat -ano | findstr "6000" | findstr "LISTEN"
TCP 0.0.0.0:6000 0.0.0.0:0 LISTENING 2768
C:\> tasklist /fi "pid eq 2768"
Image Name PID Session Name Session# Mem Usage ========================= ======== ================ =========== ============ Xming.exe 2768 Console 1 20 060 Ko
In Putty sessions, enable the option X11 forwarding for SSH (Menu : ConnectionSSHX11).
That’s all, everything is ready. Except if some firewall rules block everywhere or somewhere…
A first test : simply run an
xterm window from the server, this window should appear in the windows 10 environment :
android@vps:~$ xterm -bg black -fg yellow &
A more complicated case, to test more advanced functionalities (resizing…) : opening Android Studio 3.4
android@vps:~$ cd /software/android/android-studio android@vps:~$ ./bin/studio.sh &