{"id":2602,"date":"2021-06-20T00:39:01","date_gmt":"2021-06-20T08:39:01","guid":{"rendered":"http:\/\/wonghoi.humgar.com\/blog\/?p=2602"},"modified":"2022-03-17T00:47:18","modified_gmt":"2022-03-17T08:47:18","slug":"remote-desktop-into-linux-gui-xrdp","status":"publish","type":"post","link":"https:\/\/wonghoi.humgar.com\/blog\/2021\/06\/20\/remote-desktop-into-linux-gui-xrdp\/","title":{"rendered":"Remote Desktop INTO Linux GUI (xrdp)"},"content":{"rendered":"\n<p>To serve Linux Desktop just like other Windows computer through Windows Remote Desktop (formerly Terminal Services), so far I have found xrdp (xorgxrdp). VNCs, NX (NoMachine)\/TeamViewer does not count because they share the screen of an existing session, instead of creating a new one for you.<\/p>\n\n\n\n<p>Xrdp does not follow the use pattern as Microsoft&#8217;s RDP. When you log in to a Xrdp host (server) through a RDP client, you go into an intermediary (welcome interface) called sesman (Session Manager), which is a multi-protocol remote graphical session client (think of it as a very rudimentary Remmina). <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"496\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/06\/image-1024x496.png\" alt=\"\" class=\"wp-image-2603\" srcset=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/06\/image-1024x496.png 1024w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/06\/image-300x145.png 300w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/06\/image-768x372.png 768w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2021\/06\/image.png 1105w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption>&#8220;Session&#8221; is the roughly same as protocol, which formerly and internally it&#8217;s called &#8220;Module&#8221; as the client programs are in implemented lib*.so object module file.<\/figcaption><\/figure>\n\n\n\n<p>The two session modules we are interested in here is <\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Xorg (libxup.so): Xorgxrdp is the MS-RDP-like mode that starts a new X session without first attaching to a screen.<\/li><li>Xvnc (libvnc.so): basically a VNC client. You start a VNC server (like X11vnc) with a display\/screen (can be started in any X session you logged in, or the local user screen if you <a href=\"https:\/\/wonghoi.humgar.com\/blog\/2021\/06\/18\/run-vnc-server-before-logging-to-linux-gui\/\" data-type=\"post\" data-id=\"2589\">set the VNC server as a service<\/a>) and connect to it in this RDP intermediary (welcome interface) without installing VNC client software.<\/li><\/ul>\n\n\n\n<p>In Windows, RDP do not distinguish between local and remote users and sessions with the same login account will take over other existing sessions. If you want each session to start fresh and leave other sessions alone, disable this in Group Policy Object editor under <code>Computer Configuration &gt; Administrative Templates &gt; Windows Components &gt; Remote Desktop Services &gt; Remote Desktop Session Host &gt; Connections -&gt; \"Restrict Remote Desktop Services user to a single Remote Desktop Services session<\/code>&#8220;. <\/p>\n\n\n\n<p>I am usually fine with this arrangement as well, but often prefer to connect to my remote sessions work in the background leaving the local user alone (i.e. if I want things to show up on the local monitor screen, I&#8217;ll use VNC instead). I&#8217;d also like to resume my <strong>remote<\/strong> sessions if I log in from another computer instead of starting from scratch with each new RDP connection. Turns out given a bunch of quirks of xrdp, this is much easier to do so than reproducing MS-RDP&#8217;s default behavior.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Allow overtaking of locally logged-in session<\/h2>\n\n\n\n<p>First of all, out of the box, the same remote user <a rel=\"noreferrer noopener\" href=\"https:\/\/c-nergy.be\/blog\/?p=16682\" target=\"_blank\">cannot overtake <strong>locally<\/strong> logged-in<\/a> desktops nor be simultaneously logged in! It&#8217;s either one way or the other! I got bumped out immediately after logging in through sesman, or if I logged in remotely first, I get bumped out when I try to log in locally.<\/p>\n\n\n\n<p>Found <a href=\"https:\/\/catch22cats.blogspot.com\/2018\/05\/xrdp-blank-screen-with-ubuntu-1804.html\">somebody suggested<\/a> that certain desktop environment might have added code to prevent the second session from opening. And this <a href=\"https:\/\/c-nergy.be\/blog\/\">blog<\/a> suggested you edit the windows manager launch script<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">sudo nano \/etc\/xrdp\/startwm.sh<\/pre>\n\n\n\n<p>to add EITHER <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">unset DBUS_SESSION_BUS_ADDRESS\nunset XDG_RUNTIME_DIR<\/pre>\n\n\n\n<p>OR<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">export $(dbus-launch)<\/pre>\n\n\n\n<p>RIGHT BEFORE the last lines which checks and calls the Xsession<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>test -x \/etc\/X11\/Xsession &amp;&amp; exec \/etc\/X11\/Xsession<br>exec \/bin\/sh \/etc\/X11\/Xsession<\/code><\/pre>\n\n\n\n<p>This only solves the part of simultaneous local &amp; remote logons<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>In the newer version as of writing, the default behavior is that locally logged in sessions are independent of remotely logged in sessions, yet the remotely logged in sessions resumes by default (if you log in as the same user). <\/p>\n\n\n\n<p>Turns out this is what I preferred as the local sessions should be reached with VNC instead and I&#8217;d prefer my remote sessions happen at the background without showing it on the local screen.<\/p>\n\n\n\n<p>As of now (2020-03-17), the author of xrdp mentioned in his <a rel=\"noreferrer noopener\" href=\"https:\/\/c-nergy.be\/blog\/?p=16698\" target=\"_blank\">blog<\/a> that a remote session cannot take over a locally logged in session like Windows RDP does:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"471\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2022\/03\/image-18-1024x471.png\" alt=\"\" class=\"wp-image-3750\" srcset=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2022\/03\/image-18-1024x471.png 1024w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2022\/03\/image-18-300x138.png 300w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2022\/03\/image-18-768x353.png 768w, https:\/\/wonghoi.humgar.com\/blog\/wp-content\/uploads\/2022\/03\/image-18.png 1257w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Generic VNC client hosted on RDP server<\/h2>\n\n\n\n<p>The interface also offer a built-in VNC client that you can use it to connect to your current session if you have VNC server enabled so you don&#8217;t have to install a separate VNC client from the client machine you are connecting from. In other words, xorgxrdp self-hosts a VNC client within xrdp so you can use your RDP as a VNC client.<\/p>\n\n\n\n<p>Since the VNC server (like x11vnc) only has a password (not using system&#8217;s active directory or user management system), there is no user name. I went to <strong><code>[Xvnc]<\/code> section of <code>xrdp.ini<\/code> and replaced <code>username=ask<\/code> with <code>username=na<\/code><\/strong>. The port number -1 no longer applies as we aren&#8217;t emulating RDP with VNC anymore (where sesman creates a new VNC server instance if not previously done). Given that I&#8217;m running VNC as a service at default port 5900, I also changed it to <code>port=5900<\/code>.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Other less important features in xorgxrdp<\/h2>\n\n\n\n<p>Session\/Module &#8220;vnc-any&#8221; uses the same libvnc.so as Xvnc before it, and they are pretty much the same thing except it exposes ip:port entry so you can use it as a gateway to connect to VNC servers hosted on other machines (can be used to connect to the VNC server on the current machine you just connected to through RDP if you stick with 127.0.0.1:5900). It&#8217;s more like a convenience thing that hosts the VNC client software that you can RDP into (so you don&#8217;t need to install a VNC client from where you are).<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>There is also a RDP client module\/session called &#8216;neutrinordp-any&#8217;, which basically uses the linux machine you just connected to as a gateway to visit another machine hosting RDP. It&#8217;s rarely useful and it doesn&#8217;t work out of the box when I tried it (does nothing after I press OK despite entering all the info correctly). So I removed it from my xrdp.ini<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Minor annoyances to deal with in xrdp<\/h2>\n\n\n\n<p>There&#8217;s also a minor annoyance that if you connect remotely, \u201cAuthentication Required\u2026\u201d&nbsp;message box will show up on start since remote user is a little more restrictive than local users. This can be solved by creating this file with nano<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nano \/etc\/polkit-1\/localauthority\/50-local.d\/46-allow-update-repo.pkla<\/code><\/pre>\n\n\n\n<p>and paste the contents there and save it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[Allow Package Management all Users]\nIdentity=unix-user:*\nAction=org.freedesktop.packagekit.system-sources-refresh\nResultAny=yes\nResultInactive=yes\nResultActive=yes<\/pre>\n<div class=\"pvc_clear\"><\/div><p id=\"pvc_stats_2602\" class=\"pvc_stats all  \" data-element-id=\"2602\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p><div class=\"pvc_clear\"><\/div>","protected":false},"excerpt":{"rendered":"<p>To serve Linux Desktop just like other Windows computer through Windows Remote Desktop (formerly Terminal Services), so far I have found xrdp (xorgxrdp). VNCs, NX (NoMachine)\/TeamViewer does not count because they share the screen of an existing session, instead of &hellip; <a href=\"https:\/\/wonghoi.humgar.com\/blog\/2021\/06\/20\/remote-desktop-into-linux-gui-xrdp\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"pvc_clear\"><\/div>\n<p id=\"pvc_stats_2602\" class=\"pvc_stats all  \" data-element-id=\"2602\" style=\"\"><i class=\"pvc-stats-icon medium\" aria-hidden=\"true\"><svg aria-hidden=\"true\" focusable=\"false\" data-prefix=\"far\" data-icon=\"chart-bar\" role=\"img\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 512 512\" class=\"svg-inline--fa fa-chart-bar fa-w-16 fa-2x\"><path fill=\"currentColor\" d=\"M396.8 352h22.4c6.4 0 12.8-6.4 12.8-12.8V108.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v230.4c0 6.4 6.4 12.8 12.8 12.8zm-192 0h22.4c6.4 0 12.8-6.4 12.8-12.8V140.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v198.4c0 6.4 6.4 12.8 12.8 12.8zm96 0h22.4c6.4 0 12.8-6.4 12.8-12.8V204.8c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v134.4c0 6.4 6.4 12.8 12.8 12.8zM496 400H48V80c0-8.84-7.16-16-16-16H16C7.16 64 0 71.16 0 80v336c0 17.67 14.33 32 32 32h464c8.84 0 16-7.16 16-16v-16c0-8.84-7.16-16-16-16zm-387.2-48h22.4c6.4 0 12.8-6.4 12.8-12.8v-70.4c0-6.4-6.4-12.8-12.8-12.8h-22.4c-6.4 0-12.8 6.4-12.8 12.8v70.4c0 6.4 6.4 12.8 12.8 12.8z\" class=\"\"><\/path><\/svg><\/i> <img loading=\"lazy\" decoding=\"async\" width=\"16\" height=\"16\" alt=\"Loading\" src=\"https:\/\/wonghoi.humgar.com\/blog\/wp-content\/plugins\/page-views-count\/ajax-loader-2x.gif\" border=0 \/><\/p>\n<div class=\"pvc_clear\"><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[39],"tags":[],"class_list":["post-2602","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2602","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/comments?post=2602"}],"version-history":[{"count":10,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2602\/revisions"}],"predecessor-version":[{"id":3751,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/posts\/2602\/revisions\/3751"}],"wp:attachment":[{"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/media?parent=2602"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/categories?post=2602"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wonghoi.humgar.com\/blog\/wp-json\/wp\/v2\/tags?post=2602"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}