4

Is there a way to take a screenshot of what is on screen by being remotely logged on that machine with ssh?
Vnc is no good, since AFAIK it cannot take ownership of an existing X session.

3
  • as the user owning the x11-session you are interested in?
    – akira
    Dec 22 '10 at 14:13
  • @akira Yes. (some more characters)
    – mbq
    Nov 18 '13 at 16:32
  • I use this simple script to peep into the other pc: askubuntu.com/questions/194427/…
    – xerostomus
    Nov 29 '20 at 8:34
13

You might want to try this:

xwd -out screenshot.xwd -root -display :0.0

It will save the screenshot to screenshot.xwd which GIMP should be able to open. Check out the xwd man page here: http://linux.die.net/man/1/xwd

2
  • any screenshot program will do: scrot, import (from imagemagick) etc. you just point it to the right $DISPLAY (or -display or --display or --dpy .. thats why i prefer $DISPLAY) and thats it. the main question remains unanswered: wants OP to capture a session (aka spy) on someone else?
    – akira
    Dec 23 '10 at 7:27
  • 2
    @akira There are plenty of reasons you'd want to do this other than to spy. Right now I'm connected to my work computer over SSH and trying to figure out why my code editor is using 200% CPU usage. There isn't anyone using the computer - but I left the editor open when I locked the machine. So maybe a screenshot will help diagnose the problem.
    – AnnanFay
    Jan 15 '17 at 15:55
1

Assuming you have ImageMagick installed on the remote and local machine, the X server on the remote machine is running as the user you are connecting with, you can take a screenshot remotely and display it on your local X server like this:

ssh user@example.com "DISPLAY=:0 import -window root -" | display

This is very convenient as you don't need to copy any temporary files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.