How can I share the desktop view (or view from one program) to multiple other machines (given root access) simultaneously? I've seen similar questions (e.g.,here and here), but I'm not sure how one to many simultaneously would be done.
2 Answers
You could use VNC, see this Q&A: https://softwarerecs.stackexchange.com/questions/20417/same-content-on-several-different-computers-monitors-administered-remotely/20419#20419.
A VNC server can be shared by multiple clients in "read-only" mode (i.e. clients can't control the server via keybooard or mouse) or "read-write" mode (clients can take control of the server via keyboard or mouse, but it can get tricky when multiple clients have write control simultaneously as they can interfere with each-other).
Most recent Linux distributions have the VNC support built into the X11 server itself, but it may need to be enabled (check your specific distribution documentation for instructions). Alternatively you can start a server manually, entirely independent from the "main" X11 server running on the machine. When started manually a VNC server can simultaneously support both "read-only" and "read-write" clients using different passwords (not sure if the built-in X11 server support does that).
VNC works wonderfully over SSH and clients don't even need root permissions for execution.
The goal was to distribute whatever image / program selected to ~30 Linux desktops whether or not a user was logged in, the content should supersede what the user was viewing (think PSA), and the users' actual desktop tasks should remain undisturbed. Moreover, the user should not be given the ability to alter the content. I had hoped for a basic solution using X and TCP broadcasts. That did not evolve, rather I used VNC as recommended by others.
On the client side, I set up an expect script to start a blank Xsession (e.g. X :1
), switch to that virtual terminal (i.e., chvt 1
when necessary), and connect to the vncserver.
Namely:
for num in $(seq 0 30); do expect -f xremote$num.exp; done
where each xremote script specifies the remote host:
set timeout -1
spawn ssh -o ConnectTimeout=10 root@somehost1
match_max 100000
expect "#"
send "X :1 & \r"
expect "#"
send "export DISPLAY=:1 \r"
expect "#"
send "vncviewer -passwd /root/.vnc/passwd -Shared -ViewOnly -FullScreen 192.168.1.1:1& \r"
expect "#"
send "exit\r"
expect eof
exit 0
and the server dishes up content on :1 after:
vncserver :1 -geometry 1024x768 -depth 16
Afterwards, it got a bit tricky to close out the Xsessions on the clients. So I used the following expect script to close out all the Xsessions [X restarts automagically on :0] :
set timeout -1
spawn ssh -o ConnectTimeout=10 root@somehost1
match_max 100000
expect "#"
send "pkill X \r"
expect "#"
send "chvt 1 \r"
expect "#"
send "rm /tmp/.X*lock \r"
send "exit\r"
expect eof
exit 0