Remote Desktop: Difference between revisions

Pigs (talk | contribs)
Use current channel for search.nixos.org links
Tags: Mobile edit Mobile web edit Advanced mobile edit
Crazivik (talk | contribs)
Updated XRDP Subsection, Major Update to Gnome RDP Section, Minor formatting changes.
Line 1: Line 1:
= Software =
== Software ==


Remote desktop software is split into two types: servers and clients.
Remote desktop software is split into two types: servers and clients.
Line 7: Line 7:


* VNC
* VNC
* XRDP
* RDP
 


== Self hosting ==
== Self hosting ==
Line 22: Line 21:
* GNOME Connections
* GNOME Connections
* [[RustDesk]]
* [[RustDesk]]
= Configuration =


== VNC ==
== VNC ==
Line 30: Line 27:
Various servers provide configuration options either by CLI or by configuration file.
Various servers provide configuration options either by CLI or by configuration file.


==== Desktop session ====
=== Desktop session ===


To start a desktop session or window manager, one currently has to do this manually because servers still have hard-coded paths to <code>/usr/share/xsessions</code> to look for <code>.desktop</code> files. That means one has to write a script that starts the desktop session, window manager, or any other X application.
To start a desktop session or window manager, one currently has to do this manually because servers still have hard-coded paths to <code>/usr/share/xsessions</code> to look for <code>.desktop</code> files. That means one has to write a script that starts the desktop session, window manager, or any other X application.
Line 217: Line 214:
== RDP ==
== RDP ==


=== XRDP ===
[[File:Screenshot from 2024-03-02 03-15-05.png|thumb|right|GNOME running in an XRDP shell in Remmina.]]
NixOS has first-class support for XRDP. Client-wise, RDP can be accessed in many ways, but `remmina` and `freerdp` support it natively.
NixOS has first-class support for XRDP. Client-wise, RDP can be accessed in many ways, but `remmina` and `freerdp` support it natively.


Line 234: Line 233:
(Source: [https://discourse.nixos.org/t/please-post-working-xrdp-setting-in-configuration-nix/7404/10 Discourse Link], [https://github.com/NixOS/nixpkgs/blob/86a80807d8d7051c63ab2b9d7f630abe066468b1/nixos/modules/services/networking/xrdp.nix nixpkgs code])
(Source: [https://discourse.nixos.org/t/please-post-working-xrdp-setting-in-configuration-nix/7404/10 Discourse Link], [https://github.com/NixOS/nixpkgs/blob/86a80807d8d7051c63ab2b9d7f630abe066468b1/nixos/modules/services/networking/xrdp.nix nixpkgs code])


A different window manager can be used for XRDP than a machine user, provided it has been enabled (through NixOS <code>services</code> or <code>nixpkgs</code>.
A different window manager can be used for XRDP than a machine user, provided it has been enabled (through NixOS <code>services</code> or <code>nixpkgs</code>.  


Make sure you log out the visual user first on the remote machine, otherwise you'll get a black screen. (Source: [https://www.reddit.com/r/Proxmox/comments/hxp28j/black_screen_in_microsoft_remote_desktop_noob/fzm7zbo/ Reddit]). You may be able to work around this by enabling and configuring [[Polkit]], as demonstrated on that page.
Make sure you log out the visual user first on the remote machine, otherwise you'll get a black screen. (Source: [https://www.reddit.com/r/Proxmox/comments/hxp28j/black_screen_in_microsoft_remote_desktop_noob/fzm7zbo/ Reddit]). You may be able to work around this by enabling and configuring [[Polkit]], as demonstrated on that page.


=== GNOME ===
==== XRDP with Gnome 48 and higher ====
[[File:Screenshot from 2024-03-02 03-15-05.png|thumb|right|GNOME running in an XRDP shell in Remmina.]]
<syntaxhighlight lang="nix">
 
services.xrdp.enable = true;
services.xrdp.defaultWindowManager = "${pkgs.gnome-session}/bin/gnome-session"; # gnome wayland session
services.gnome.gnome-remote-desktop.enable = true; # needs gnome-remote-desktop backend to work!!
services.displayManager.autoLogin.enable = false;
services.getty.autologinUser = null;
networking.firewall.allowedTCPPorts = [ 3389 ];
</syntaxhighlight>
 
=== GNOME RDP ===
 
To enable the built in gnome-rdp, setting <code>services.gnome.gnome-remote-desktop.enable = true;</code> is not enough by itself. This installs the systemd unit but the unit does not start automatically at boot. As a consequence the 'Remote Desktop' configuration option is also not available in 'System' tab of the 'Settings' app.
 
To fix this we need to enable and start the systemd unit at boot using <code>wantedBy = [ "graphical.target" ];</code> as shown below:


The XRDP <code>defaultWindowManager</code> setting to access a remote GNOME shell should be set to <code>gnome-remote-desktop</code>. Also ensure you include the package <code>pkgs.gnome.gnome-remote-desktop</code> in your configuration files and that you have a firewall port open for XRDP to communicate on (for the GNOME connections app, this is usually <code>3389</code>).
<syntaxhighlight lang="nix">services.gnome.gnome-remote-desktop.enable = true; # 'true' does not make the unit start by default at boot
systemd.services.gnome-remote-desktop = {
  wantedBy = [ "graphical.target" ]; # for starting the unit by default at boot
};
services.displayManager.autoLogin.enable = lib.mkForce false;
services.getty.autologinUser = lib.mkForce null;
networking.firewall.allowedTCPPorts = [ 3389 ];</syntaxhighlight>


=== Meshcentral ===
=== Meshcentral ===