Linux X screenshot using xwd

I'm trying to get the console (X display) screenshot from remote machine.
usera is login on the console and use display 0.0.
I want to get his screenshot.
I'm login using ssh as root, trying to:

prompt> xwd -root -out screenshot.xwd -display 0:0
Xlib: connection to "0:0.0" refused by server
Xlib: No protocol specified
xwd:  unable to open display '0:0'

The same for:
prompt> xwd -root -out screenshot.xwd -display

Adding all  to the xhost list fail:
prompt> xhost +
xhost:  unable to open display ""
The system os in redhat 8 Linux.

Who is Participating?
liddlerConnect With a Mentor Commented:
I'm not sure you've got you : and . correct
liddler is right.

First step: set the DISPLAY variable on your target system: DISPLAY=:0.0 (:0 is the device, .0 is the screen)
Second step: xhost +

To enable a remote name by default, the name can be defined in the /etc/X?.hosts file, where ? is the display number to which you enable access.
GnsConnect With a Mentor Commented:
This is (as you correctly deduce) a problem related to the remote X seerver denying you access. There is no way for you to amend this other that to intruct usera to allow localhost access (blithely letting remotes "in" isn't recommeded.... at least not by me:-). Havi him/her do
xhost + localhost
in an xterm, then do the "localhost xwd" above.

-- Glenn
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

As far as I can see I'm correct here... Although liddler is right that the first instance of the xwd command (in the Q) has a flawed display specification, the second ( is equivalent to setting it to :0 ... And since that doesn't work, one can surmise that root lacks the proper credentials. Ergo, Adaddy needs do what I say (for the running instance... and perhaps add an explicit xhost + localhost in a suitable X startup script),

-- Glenn
I think this one has been missed in a cleanup
liddler ,

Yeah... And after that I reduced my work as a CV for a while...
Handled now :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.