Can I start my main desktop graphical session remotely?

14,518

Solution 1

You can start a console GUI session remotely: run startx. However, that's likely not to work because you'll lack the permission. On most setups, only the user physically logged in on the console is allowed to use the console.

Different distributions have adopted different mechanisms to control who can start an X session on the console. I believe that on RHEL this is done through systemd, but I don't know how.

If you start an X application on the console display, you won't be able to interact with it remotely. There are a few exceptions such as Emacs that are capable of connecting to multiple displays, but in general X applications open a connection to the X display when they start and never look back. You can use Xmove or Xpra to mediate between the X server and the application; an X application started inside Xmove or Xpra can be moved to a different X server (like detaching and attaching a screen session).

Another option once you've started the console X session would be to interact with it remotely. You can use X11vnc for that, and access the remote session with a VNC client.

Solution 2

I'd suggest a look at the following projects (although I kind of doubt that xpra can handle a whole session)

  • the x2go terminal server project seems pretty well for this task (see this Linux Magazine article); however it could be a little over-the-top for a smallish setup.

  • xpra:

    Xpra is 'screen for X': it allows you to run X programs, usually on a remote host, direct their display to your local machine, and then to disconnect from these programs and reconnect from the same or another machine, without losing any state. It gives you remote access to individual applications.

And have a look around, some other tools have also been mentioned here already (e.g. here).

(Something more direct might be possible (see this note of "startx over ssh"), but it the "picking up where I left part" will not work.)

Edit Something just crossed my mind -- if you use some desktop manager that supports auto-login (say, slim, nodm, gdm3, kdm); you should be able to start a session for one specific user on :0 (via, say, /etc/init.d/gdm3 start).

And there is XDMCP (with security concerns).

Share:
14,518

Related videos on Youtube

FrenchKheldar
Author by

FrenchKheldar

Updated on September 18, 2022

Comments

  • FrenchKheldar
    FrenchKheldar almost 2 years

    So my workstation at work got rebooted and I'm currently not logged in physically there with a graphical session. I have ssh access to it, and I can start a new X windows session and use my graphical applications remotely. I was just wondering if there was a way to start the main desktop session remotely, so that I can then connect and interact with it and next time I get in front of the workstation, I can just pick up where I left off...

  • FrenchKheldar
    FrenchKheldar over 11 years
    Thanks these are interesting. But I guess there is no way to perform a remote login that accomplish the same thing as a physical login (ie start display:0).
  • FrenchKheldar
    FrenchKheldar over 11 years
    Well that's more what I had in mind. If I can run startx then I can connect to the main X server (:0) and interact with my main desktop. I will try and let you know what happens.
  • Piotr Dobrogost
    Piotr Dobrogost almost 7 years
    @FrenchKheldar I will try and let you know what happens. What happened?
  • Piotr Dobrogost
    Piotr Dobrogost almost 7 years
    However, that's likely not to work because you'll lack the permission. Could you please elaborate on this in your answer? Does it mean that remote users are not supposed to start X server at all? If not then is there any accepted/canonical way of starting X server remotely? Alternatively you might want to add links answering my questions.
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' almost 7 years
    @PiotrDobrogost Users are supposed to be logged in on the console in order to start a GUI session on the console. That's because if you aren't logged in on the console, you don't have access to the console peripheral. You can start an X server remotely, but it can't access the console, e.g. it can be Xvfb (displaying in a framebuffer in memory) but not Xorg (displaying on an actual screen). Only the administrator (root) may take control of the console (including starting an X server there) without being logged in on it.
  • FrenchKheldar
    FrenchKheldar almost 7 years
    @PiotrDobrogost If I recall correctly, it didn't work. But it's been a while !
  • Jack Wasey
    Jack Wasey about 4 years
    I was hoping this question was referring to simulating a console login via gdm3 (etc) from an ssh connection. The nextcloud sync depends on GUI right now, or writing one's own cron/inotify/systemd-path code to do it. I just want to do a regular console login, but without sitting in front of the workstation. Any ideas?
  • Gilles 'SO- stop being evil'
    Gilles 'SO- stop being evil' about 4 years
    @JackWasey If you aren't at the console, then by definition you aren't at the console. If you want a GUI remotely, just use SSH as usual, with X11 forwarding enabled.