On Windows machines, if one machine A runs the remote desktop service, and another machine B (which in fact doesn't have to be Windows) runs a remote desktop client – then the user on B can 'steal' control of the session on A, see the app windows which were opened there and interact with them. Note that RDP also allows you to open a new session if there's no existing one, but that's not what the question is about.
My question: How can I achieve the same with A being a Linux machine, running an X server with an X session in progress.
Notes:
- A solution need not be based on MSRDP itself, it could be NX, or VNC, or whatever else you like.
- I'm willing to install software on A and on B, including installation as the root user.
- Commercial solutions are relevant, though I would rather not resort to them.
- Solution may involve opening additional ports on A (in addition to, say, port 22 for SSH).
- Assume the distributions are Debian-based and fairly recent.
- This question is similar to this one, but it's not the same, since : 1. I'm willing to run services other than just X and 2. In that question, the OP seems more interested in getting specific windows, while for me it's important to see the whole thing.
- Solutions in which both the users on A and B can interact with the same session are also relevant.
Best Answer
To take control of a running X session you will need to configure your VNC server to connect to the same display as X. Generally, X will be connected to the first display -
:0
.You will also need the X Authority for that X session. This can be found by accessing the X Authority file that the remote Display Manager is using. This depends on your Display Manager and can be found using
ps aux
andgrep
. For example:psaux | grep Xorg
gives you something similar to:Note the
-auth
option as you'll need it with VNC. You then need to run something like the following asroot
on the remote computer after installingx11vnc
:The easiest way would be to create a service that runs this for you on boot. On distros that use
systemd
, create a file/etc/systemd/system/x11vnc.service
similar to the following:Note the
-rfbauth
option. You'll need to create the password file beforehand using:Alternatively, if you don't feel you need password protected VNC sessions, then simply remove the
-rfbauth
line.Enable at boot with:
Start it manually with:
You can now connect to the remote computer with your VNC client and take over the session.