SSH Periodic Screenshot

October 08, 2014

I came up with this fairly scary bash one liner that will periodically ssh into a machine that you have access to, take a screenshot and copy it back to your machine. Just fill in the USER and HOST variables.

USER=www-data; HOST=dev0; bash -c "while [ 0 ]; do ssh $USER@$HOST DISPLAY=:1.0 import -window root /tmp/a.png; date +%s | xargs -I {} scp $USER@$HOST:/tmp/a.png $USER@$HOST-{}.png; sleep 2; done"

Profile picture
Written by Lucas Doyle, an engineer living in San Francisco
© 2021