How to start KDE Plasma session remotely (via ssh)?

How can I start KDE Plasma session after logging in to the remote host via ssh?
The reason I need this is because then I want to use a tool like KRdp or RustDesk to have remote access to such a session.

Trying startplasma-wayland ends with the error:

$ startplasma-wayland
Error: could not determine $DISPLAY.
Error: Can not contact kdeinit5!
org.kde.startup: "kdeinit5_shutdown" QList() exited with code 255
startplasma-wayland: Shutting down...
startplasmacompositor: Shutting down...
startplasmacompositor: Done.
Output from `kinfo`
$ kinfo
Operating System: Fedora Linux 41
KDE Plasma Version: 6.3.3
KDE Frameworks Version: 6.12.0
Qt Version: 6.8.2
Kernel Version: 6.13.9-200.fc41.x86_64 (64-bit)
Graphics Platform: offscreen
Processors: 12 × AMD Ryzen 5 7600 6-Core Processor
Memory: 14.8 GiB of RAM

I asked this also here How to start KDE Plasma session remotely (via ssh)? · Issue #2070 · sddm/sddm · GitHub

Related

Btw, could someone please create a tag plasma-session?

I don’t believe you can. If you want to start a graphics session you have to do so from the actual device (I could be wrong but at least that has been my experience)
What I did to solve the same issue was to switch the SDDM compositor from kwin to sway so I could install wayvnc, which I access via ssh tunnel. This allows me access to SDDM via vnc, so I can log into my plasma session, I think switch to RDP to remote-desktop into the started session.

Happy to provide the sddm conf and sway conf that I use if it’s helpful.

Thanks for replying. However interesting you did get it to work I find this is too much fiddling for my test. :wink:

I guess this must be your answer then
Start KDE (wayland) after reboot from SSH session (not autologin) / Applications & Desktop Environments / Arch Linux Forums :wink:

yes works great,

I just wrote a long post about this since I had to figure it out myself.

TL;DR:

systemd-run --uid="$(whoami)" -p PAMName=login -E XDG_SEAT=seat0 \
  -E XDG_VTNR=1 -E XDG_SESSION_TYPE=tty -E XDG_SESSION_CLASS=user \
  startplasma-wayland
1 Like

Hi @dblsaiko , thanks so much for sharing this and the background article! :slight_smile: Well written which makes it easy to understand. It was exactly what I was looking to do myself, but couldn’t and still can’t fully figure out.

TLDR: Can you maybe describe the steps you take to launch and login to your graphical session remotely, and then start the RDP session? I’m trying to achieve something similar (remote graphical session through sunshine + moonlight instead of RDP), but can’t figure out how to do this in practice.

My purpose is to get my desktop (gaming) PC up and running remotely, so that I can stream games from it to my laptop remotely. For this I need to remotely start and login to a graphical desktop session (amongst other things).

When I login to the booted computer via SSH and execute the command you supplied I do indeed see a graphical interface starting, however there’s no panels, no run command command box nor is any other service being started that normally start when I login. Therefore I have no way to launch applications in this graphical environment/session itself. Launching them through the SSH session also doesn’t work as it can’t find a display (which of course makes sense :slight_smile: ). How do I get a fully functional Plasma session up and running, so that I can at least start sunshine?

1 Like

Interesting. Tbh I have only tested this on my computer (Gentoo, systemd), so the start process might work differently for you depending on the exact setup/distro, and you might need something extra to get it to work correctly. But in theory startplasma-wayland should end up starting the plasma-workspace-wayland.target user target which should trigger all the services like the plasmashell to launch. And if you’re getting the display set up even if nothing else runs then that’s a good start at least.

How do you typically start Plasma? Which distro are you using? Did you verify that you are actually getting the correct seat assigned in loginctl (if the display is working, then you should I think)? What is the state of your user session (any failed services – systemctl --user --failed)? Can you post a copy of your user journal when doing this? (journalctl -b --user) that is, reboot, run the systemd-run … startplasma-wayland command, then check journalctl.

It turns out launching it this way is also not perfect for me, as when I came back home to my PC I noticed none of the physical input devices worked and I had to log out via RDP. So that’s something else to figure out still, I didn’t look into it further.

FWIW, the bare minimum to start an application over SSH with an already working Plasma session for me seems to be just setting WAYLAND_DISPLAY=wayland-0. Nothing extra needed.

EDIT: oh, and as for how I start it, it’s literally just this command I linked, after a fresh restart of the computer. Though I didn’t use this exact one myself, I instead used the previous one in my article that gives you a shell, and then ran startplasma-wayland from there. That should also give you a log immediately, try that, maybe it’ll also give some hints.