Command line, services and exit statuses

Most people start the server from the GUI or let the packaged systemd user service start it at login. This page is for everything else: The options lamco-rdp-server takes, the service and socket units, how to start the server only when a client connects, where the log goes, and what the server's exit status means when it stops by itself. Everything here is as of 1.4.6.

Running the server

# Native install
lamco-rdp-server
lamco-rdp-server --config ~/.config/lamco-rdp-server/config.toml -v

# Flatpak (the server, not the GUI)
flatpak run --command=lamco-rdp-server io.lamco.rdp-server

# Snap
lamco-rdp-server

The server runs inside your Wayland session, as you, and needs that session's environment (WAYLAND_DISPLAY). Run it from a terminal in the desktop, from the GUI, or from the user service; not over a plain SSH login.

Options

OptionWhat it does
-c, --config PATHThe configuration file. Default: ~/.config/lamco-rdp-server/config.toml (native, user), /etc/lamco-rdp-server/config.toml (native, root), ~/.var/app/io.lamco.rdp-server/config/config.toml (Flatpak)
-l, --listen ADDRListen address; also LAMCO_RDP_LISTEN_ADDR. The default [::]:3389 accepts IPv6 and IPv4
-p, --port PORTListen port; also LAMCO_RDP_PORT. Overrides the config only when given
-v, --verboseMore logging; repeat for more (-vv)
--log-format FORMATpretty (default), compact or json
--log-file PATHAlso write the log to a file
--set-nla-passwordStore the NLA password in the secret store and exit. Reads it without echo, or from stdin when stdin isn't a terminal. The username stays in [security.credssp_credentials]
--clear-nla-passwordRemove the stored NLA password and exit
--grant-permissionAsk the desktop for the screen-sharing permission now, store it for later starts, and exit. Useful for setting up a machine before anyone connects
--clear-tokensRemove every stored permission (restore token), so the desktop asks again
--persistence-statusShow whether a permission is stored, the deployment detected, and where credentials are kept
--show-capabilitiesShow the compositor, portals and capabilities detected, and exit. --format json for machine-readable output
--diagnoseRun diagnostic checks (deployment, portal connection, credential storage) and exit
--generate-configPrint a fully commented config.toml with every default: lamco-rdp-server --generate-config > config.toml
--dbus-serviceRun as the D-Bus service the GUI manages (what the user unit runs). --system uses the system bus, for the system unit
--licensesPrint third-party license notices, including Cisco OpenH264, and exit
-V, --version-V prints the version; --version also prints the commit it was built from and the build time
-h, --helpThe option list

In the Flatpak, put flatpak run --command=lamco-rdp-server io.lamco.rdp-server in front of any option. Start with --show-capabilities when something doesn't work; the Troubleshooting page uses it throughout.

The user service

Native packages install the systemd user unit app-io.lamco.rdp-server.service. The Debian and Ubuntu packages enable it for every user, so the server starts at login. Its old name, lamco-rdp-server.service, still works as an alias.

systemctl --user enable --now app-io.lamco.rdp-server.service
systemctl --user status app-io.lamco.rdp-server
systemctl --user restart app-io.lamco.rdp-server
systemctl --user disable --now app-io.lamco.rdp-server
  • The unit is named after the app id so the desktop's portal recognizes the server and keeps its remembered permission.
  • systemctl --user status shows the server's state line, for example while it waits on the permission dialog.
  • It restarts after a failure, and not after exit statuses 69, 77 or 78 (below).
  • Its only hardening is UMask=0077, LimitCORE=0 and KeyringMode=private. Directives that set no_new_privs or a private mount namespace would stop PAM sign-in and pasted files, so don't add them in a drop-in; see Security.
  • To start the server at boot without logging in, enable lingering: sudo loginctl enable-linger $USER. The server still needs a desktop session to share.

The Flatpak and the Snap have no unit of their own. Use "Start the server when I log in" on the GUI's Server tab, which works in every package.

Starting when a client connects

Native packages also install app-io.lamco.rdp-server.socket, not enabled. Enable it in place of the service, and systemd holds port 3389, starts the server when a client connects, and leaves it running after.

systemctl --user disable --now app-io.lamco.rdp-server.service
systemctl --user enable --now app-io.lamco.rdp-server.socket

# Change the address or port with a drop-in
systemctl --user edit app-io.lamco.rdp-server.socket
# [Socket]
# ListenStream=
# ListenStream=127.0.0.1:3390
  • Started this way, the server asks the desktop for its session only once a client has signed in, so a connection that never signs in raises no permission dialog.
  • It needs a sign-in for that. With auth_method = "none" and no NLA password it refuses to start unless the socket listens on a loopback address.
  • ListenStream= sets the address; server.listen_addr applies only when the server opens the port itself.
  • Where the service is enabled too, the service started at login takes the socket's port and behaves the same way.

When the desktop is asked

The server listens as soon as it starts. When it asks the desktop for its session, which is when a permission dialog can appear, is set by server.desktop_session, also a switch on the GUI's Server tab:

ValueBehavior
"at-start" (default)As soon as the server starts. A client that signs in before the desktop is there sees "Starting the remote desktop", then "Waiting for permission on HOST's screen", and the same connection becomes the desktop when permission is given
"on-connect"When the first client has signed in. Nothing is asked for or shared before that, and the session stays for later connections. Needs a sign-in unless the server listens on localhost

With "on-connect", server.release_when_idle = true lets the session go a minute after the last client leaves, so the desktop shows no sharing indicator while nobody's connected, and asks again (silently, once the permission is remembered) at the next sign-in. Ways to start with nobody at the screen on each desktop are in the desktop guides, for example KDE and COSMIC.

Exit statuses

When the server stops by itself, its exit status says why, and the packaged units restart it only where that helps. The GUI shows the reason for each.

StatusMeaningThe serviceWhat to do
0Stopped normally, including on SIGTERMStays stoppedNothing
69This desktop can't be shared: It offers no way to capture the screen (Cinnamon, Weston)No restartUse a supported desktop; see supported configurations
75The desktop session was lost and couldn't be reopened in place, so a fresh server should take overRestartsNothing; after three such losses in ten minutes on COSMIC the server exits this way and the service starts it again
77Permission was declined, or the share was stopped at the computer (KDE's End item, GNOME's stop button)No restartStart the server again to share again
78No client could sign in with this configuration: NLA with no password stored, PAM that can't authenticate here, or "on-connect" with no sign-in on a routable addressNo restartFix the configuration; the log and the GUI say which
# The last exit status of the user service
systemctl --user show app-io.lamco.rdp-server -p ExecMainStatus

The system service (advanced)

The packages install the user service and socket only, and the user service is what to use: It runs inside your own desktop session, where the screen and the portals are. The source tree also carries a system unit, packaging/systemd/lamco-rdp-server-system.service, for running the server under systemd's system manager as a dedicated account. No package installs it, and the 1.4.6 release test didn't exercise it, so treat it as a starting point for your own setup.

It runs lamco-rdp-server --dbus-service --system: The management interface on the system D-Bus bus as io.lamco.RdpServer.System, instead of the session bus. --system is only valid with --dbus-service. What it needs:

  • A dedicated account, lamco-rdp, that can reach a graphical session: sudo useradd -r -s /sbin/nologin lamco-rdp. The server still shares a Wayland session, so the account needs one to share; configure its seat access through logind. The unit sets XDG_RUNTIME_DIR=/run/user/%U for it.
  • The polkit policy, packaging/polkit/io.lamco.RdpServer.policy, copied to /usr/share/polkit-1/actions/. It defines four actions: io.lamco.RdpServer.status (allowed for the active local user), and manage, configure and disconnect (each asks for an administrator's password). From 1.4.6 the system service asks polkit before each of its management methods, so reading or changing the configuration over the system bus needs the matching action.
  • PAM: The unit adds the account to the shadow group so pam_unix can read /etc/shadow under the unit's syscall filter. On distributions where /etc/shadow isn't group-readable (Fedora, mode 0000), remove the SystemCallFilter lines instead, so the unix_chkpwd helper can run.
sudo cp packaging/systemd/lamco-rdp-server-system.service /etc/systemd/system/
sudo cp packaging/polkit/io.lamco.RdpServer.policy /usr/share/polkit-1/actions/
sudo systemctl daemon-reload
sudo systemctl enable --now lamco-rdp-server-system

The unit restarts the server on failure after 10 seconds, at most five times in five minutes, and not after exit statuses 69, 77 or 78, the same rule as the user service (see exit statuses). It's hardened: ProtectSystem=strict, ProtectHome=yes, private /tmp and devices, kernel and namespace restrictions, TCP and Unix sockets only, and a @system-service syscall filter that also allows mount for the FUSE file clipboard. Its configuration, state and runtime directories are /etc/lamco-rdp-server, /var/lib/lamco-rdp-server and /run/lamco-rdp-server, created by systemd. Remote access to a machine at system level is a larger exposure than a user's own session: Use a sign-in method, and limit who can reach the port (see network).

The source tree's packaging/dbus/io.lamco.RdpServer.service is the matching session-bus activation file: Installed in /usr/share/dbus-1/services/, it starts the user service when a client asks for io.lamco.RdpServer on the session bus.

Logs

  • The user service logs to the journal: journalctl --user -u app-io.lamco.rdp-server -b. It runs with RUST_LOG=info.
  • From a terminal the log goes to stdout. -v or -vv adds detail, and --log-file PATH keeps a complete copy in a file even when the console copy drops lines under a flood.
  • Log level in the config: [logging] level ("trace" to "error").
  • When reporting a problem, attach the log from the start of the server to the failure, with --show-capabilities output.

Environment variables

LAMCO_RDP_LISTEN_ADDR and LAMCO_RDP_PORT set the address and port. Other settings can be overridden only in the form LAMCO_SECTION__KEY, never in [security], and every override applied or refused is logged.

Related