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.

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

2 Answers 2


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

  • 1
    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
    Commented Dec 23, 2010 at 7:27
  • 3
    @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
    Commented Jan 15, 2017 at 15:55

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 [email protected] "DISPLAY=:0 import -window root -" | display

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

  • Just to complement your solution, by default you should give permissions for "policy" tag with pattern="PS" attribute in /etc/ImageMagick-6/policy.xml file: <policy domain="coder" rights="read | write" pattern="PS" /> Commented Apr 25, 2023 at 19:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .