I have an Ubuntu Desktop machine. My scope is to take a screenshot of this machine via SSH. This machine is playing a video, and I would like to take a screenshot of this video via SSH. I've tried as root user:
root@user-desktop:~# export DISPLAY=:0
root@user-desktop:~# echo $DISPLAY
:0
root@user-desktop:~# scrot screenshot.png
No protocol specified
Can't open X display. It *is* running, yeah?root@user-desktop:~#
Then I've tried with DISPLAY=:0.0. instead of DISPLAY:=0 (I don't know if this matters).
root@user-desktop:~# export DISPLAY=:0.0
root@user-desktop:~# echo $DISPLAY
:0.0
root@user-desktop:~# scrot screenshot.png
No protocol specified
Can't open X display. It *is* running, yeah?root@user-desktop:~#
Then I've done the same attempts as non-root user:
user@user-desktop:~$ export DISPLAY=:0
user@user-desktop:~$ echo $DISPLAY
:0
user@user-desktop:~$ scrot screenshot.png
Invalid MIT-MAGIC-COOKIE-1 keyCan't open X display. It *is* running, yeah?user@user-desktop:~$
user@user-desktop:~$ export DISPLAY=:0.0
user@user-desktop:~$ echo $DISPLAY
:0.0
user@user-desktop:~$ scrot screenshot.png
Invalid MIT-MAGIC-COOKIE-1 keyCan't open X display. It is running, yeah?user@user-desktop:~$
X11Forwarding,AllowTcpForwarding, etc.? -- ssh builds a tunnel (which eventually several channels). terminal is just one, but we uses a lot ssh to tunnel TCP traffic. – Giacomo Catenazzi Nov 16 '22 at 09:50xhost +, so that external console programs can access X (programs not opened by X) – Giacomo Catenazzi Nov 16 '22 at 09:55scroton the same machine that runs theX11and using the local display (he doesn't need to actually display anything on the screen, he uses theDISPLAYjust soscrotcould take it's screenshot), he doesn't needxhost +. It would only be needed if you tried to runscrotfrom a remote machine using theDISPLAYof the host he wants to take the screenshot at. – aviro Nov 16 '22 at 13:10