How to take a remote screenshot on the Raspberry Pi

You can login to your Raspi using ssh -CX pi@IPADDRESS and then run

DISPLAY=:0 scrot screenshot.png

to take a screenshot of the display that is currently attached. After that, use

feh screenshot.png

(due to ssh -CX this will display the image locally on your Linux desktop) or copyscreenshot.png to your local computer using scprsyncWinSCP or any other tool.

This is useful for debugging what is happening on your display.