Xrdp server for remote desktop hot to log in to active session

Hello all

I’m trying to set up an xrdp server on NixOS

Thus far I found out from the wiki that I have to log out on the PC I’m connecting to to be able to remote in to it.

This is not a good solution to have to log out on the remote machine first to connect to it!

I would love to change the xrdp settings which usually are stored in /etc/xrdp/xrdp.ini

There is an option services.xrdp.confDir

I did set it to

services.xrdp.confDir = "/home/svr/.config";

then copied the settings files over

sudo cp /nix/store/9kvsnddw7f2vdaxy1hmfa0h51dpfm95h-xrdp.conf/xrdp.ini /home/svr/.config

after sudo nixos-rebuild switch I get the following error message:

× xrdp.service - xrdp daemon
     Loaded: loaded (/etc/systemd/system/xrdp.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Fri 2022-10-14 21:40:51 CEST; 28ms ago
    Process: 12694 ExecStartPre=/nix/store/cyic4752pvnni6y2bpi2jxp2k0092q8n-unit-script-xrdp-pre-start/bin/xrdp-pre-start (code=exited, status=0/SUCCESS)
    Process: 12698 ExecStart=/nix/store/sxch0yvfb2spj9c1an55s9ysq6gm8lf9-xrdp-0.9.9/bin/xrdp --nodaemon --port 3389 --config /home/svr/.config/xrdp.ini (code=exited, status=1/FAILURE)
   Main PID: 12698 (code=exited, status=1/FAILURE)
         IP: 0B in, 0B out
        CPU: 12ms

Oct 14 21:40:51 nixos-svr systemd[1]: Starting xrdp daemon...
Oct 14 21:40:51 nixos-svr systemd[1]: Started xrdp daemon.
Oct 14 21:40:51 nixos-svr systemd[1]: xrdp.service: Main process exited, code=exited, status=1/FAILURE
Oct 14 21:40:51 nixos-svr systemd[1]: xrdp.service: Failed with result 'exit-code'.
warning: error(s) occurred while switching to the new configuration

What could be the problem?

The default confDir built by the NixOS module seems to generate more than just xrdp.ini: nixpkgs/xrdp.nix at e06bd4b64bbfda91d74f13cb5eca89485d47528f · NixOS/nixpkgs · GitHub . It might be failing to start because some of these files are missing. The service also runs as user xrdp and group xrdp, are you sure that those have permissions to access /home/svr/.config?

I vaguely remember trying xrdp out of curiosity. If I remember correctly, it launches new sessions (and does not attach to existing ones) by design. x11vnc on the other hand is able to share an existing GUI session, although VNC is an inferior protocol.

1 Like

Thank you justinas, tried it out, looks good!

Do you start it with a shell script every time on startup?

If you’re referring to x11vnc, this is what I did to get it running:

{
  services.xserver.displayManager.sessionCommands = ''
    ${pkgs.x11vnc}/bin/x11vnc -rfbauth $HOME/.vnc/passwd &
  '';
}

You can set up the VNC password with x11vnc -storepasswd.

1 Like

a 1000 thank yous! Will try it out!