Skip to content

Instantly share code, notes, and snippets.

@extremecoders-re
Last active November 13, 2019 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save extremecoders-re/4663a5144dfb6f82f53028615fd9cb0f to your computer and use it in GitHub Desktop.
Save extremecoders-re/4663a5144dfb6f82f53028615fd9cb0f to your computer and use it in GitHub Desktop.
Access Ubuntu Remotely from Windows

Four remote desktop tools tested

Before trying out any of these ensure the system can be accessed remotely over SSH.

# apt install openssh-server
# systemctl status ssh
# systemctl enable ssh

SSH configuration is stored in /etc/ssh/sshd_config.

X11 forwarding

To use X11 forwarding the following must be specified in sshd_config

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

The meaning of the above parameters can be obtained from man sshd_config. To run a GUI app, first login with ssh -X user@ip, and then run the application like firefox. The remote GUI will be displayed locally. Works if the local system is Ubuntu. For Windows, need to install an additional Xserver app like Putty, SmartTTY, MobaXterm, WinSSHTerm, Terminals.

X2Go

X2Go is a client server application. The server part has to be installed in the Ubuntu machine we wish to access. Client applications are available for both Ubuntu and Windows.

X2Go server installation steps can be found here.

Gotchas

  • X2Go is not compatible with all Desktop Environment. In particular GNOME3 (in Ubuntu 18.04) doesn't work. However LXDE or XFCE does work. List of compatible environments. To install XFCE, run sudo apt install xfce4

  • X2Go creates a service which regularly spikes the CPU every 2 seconds. This service can be disabled or stopped using systemctl stop x2goserver.service. It runs a perl script x2gocleansession which in turn does some cleaning work every 2 seconds resulting in the CPU spikes.

Xrdp

A client server remote desktop tool. Xrdp can be installed using apt install xrdp. Check the status of the service using systemctl status xrdp.service. Enable it to autostart at boot using systemctl enable xrdp.service.

To connect to Xrdp from Windows, the builtin Remote Desktop Tool is enough. (RDP default port 3389). Third party tools like Remote Desktop Plus or mRemoteNG can also be used.

After connecting it will prompt for the user password multiple times during the RDP session. The reason for this is Polkit (Policy Kit) [1, 2]

To solve the problem, create a file /etc/polkit-1/localauthority/50-local.d/45-allow-colord.pkla with contents

[Allow Colord all Users]
Identity=unix-user:*
Action=org.freedesktop.color-manager.create-device;org.freedesktop.color-manager.create-profile;org.freedesktop.color-manager.delete-device;org.freedesktop.color-manager.delete-profile;org.freedesktop.color-manager.modify-device;org.freedesktop.color-manager.modify-profile
ResultAny=no
ResultInactive=no
ResultActive=yes

Restart RDP service. Now it will no longer prompt for colord authentication. However, still will not be able to do other actions like changing WiFi password, installing packages etc. To solve this problem, we can create a rule which allows every action.

Create a file /etc/polkit-1/localauthority/50-local.d/46-allow-everything.pkla with contents

[Allow all without authentication for members of sudo group even for ssh sessions]
Identity=unix-group:sudo
Action=*
ResultAny=yes

Vino VNC

The vino vnc server comes pre-installed with Ubuntu 18.04. It can be activated from Sharing. Ensure that "Access Options" is set to "Require a password". This will allow us to connect without being physically present at the Ubuntu machine to allow the incoming connection. Default port of VNC is 5900. Use mRemoteNG, Terminals, MobaXterm etc to connect from Windows. Also we have to enable Autologin (See below) as the server is started only after logging in to the Ubuntu Desktop.

Running 3D applications

All of the above remote desktop techniques create a Virtual Display to which the remote desktop tool connect. This virtual display is software rendered. The virtual display is not the same as the physical display connected to the Ubuntu machine.

To know the current rendering mode run glxinfo

$ glxinfo | grep Device
    Device: llvmpipe (LLVM 8.0, 256 bits) (0xffffffff)

llvmpipe is a software renderer. Applications like Genymotion will not run under a virtual display as it requires hardware accleration (See here). To use Genymotion and similar tools, we need to connect to the physical display which is hardware accelerated (GPU).

Only Vino VNC from the above is able to connect to the physical display. In this mode, the vnc server doesn't create a new virtual display but instead copies whatever is displayed on the physical screen to the remote system.

To use this mode, someone should login physically at the remote Ubuntu system before connecting via VNC. Since this is not always desirable we need to enable autologin in Ubuntu from the "Users" tool such that on boot it goes to Desktop without requiring further manual intervention. (See here].

Now we can connect via VNC in the same way to get full hardware acceleration. Run glxinfo to confirm.

$ glxinfo | grep Device
    Device: Mesa DRI Intel(R) HD Graphics 620 (Kaby Lake GT2)  (0x5916)

Note: When we are connected to the real physical display via VNC, RDP or X2Go will not work. This is because RDP creates virtual display only and we cannot have a physical display and virtual display for the same user at the same time.

Extras

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment