How to Take a Remote Screenshot in Raspberry Pi over SSH

I recently reviewed a Raspberry Pi 4 laptop with a custom interface that made it impractical to take screenshots directly on the device. So instead I had to take screenshots remotely over SSH. It’s quite easy to do. Most of the steps can be reproduced in other Linux systems, and are not specific to Raspberry Pi.

Enable SSH in Raspberry Pi

First, enable SSH either with sudo raspi-config in a terminal window and selecting 5. Interface Options, then P2 SSH

Raspberry Pi Enable SSHIf for some reason, you don’t have access to the terminal, take out the MicroSD card from the Raspberry Pi board, and from a computer create a new empty file named “ssh” in the boot partition.

Now provided you have the username and password for your board, you can connect to SSH with the IP address from a terminal:

or a program like Putty.

Taking a screenshot remotely

You’re now ready to take a screenshot as follows:

scrot is the program taking the screenshot, DISPLAY defines the display to capture, and the third argument is the filename that can be with png, jpg, or gif extension.

You can take as many screenshots as you’d like with different filenames, then transfer them back to your computer over SSH either from the command line inside Raspberry Pi:

or from your computer using Filezilla or other programs supporting SFTP (SSH File Transfer Protocol).

Save a Raspberry Pi Screenshot directly on Your Computer

If you’d like to be able to directly take a screenshot on Raspberry Pi with the image saved directly on your computer you can do by first setting up no password ssh using public/private keys in order to avoid having to input the password each time.

Once you’re done you should not be asked the password anymore when logging over SSH to your Raspberry Pi:

Then there are two ways to proceed from here either initiate the command from a Linux computer or from the Raspberry Pi board.

Initiate Command from a Linux Computer

Get back to the terminal window in your computer, and run the following command to take a screenshot remotely and save the file in your computer:

For each new screenshot simply change the value of FILE variable. The command line connects to Raspberry Pi over SSH, takes a screenshot, transfers it to your computer, and deletes it from the Raspberry Pi board.

Alternative methods

Screenshotting with maim

As pointed out in the comments, using maim is a more elegant method as it outputs the screenshot to stdout allowing us to save the image to the local computer with a simple redirect.

First, install maim on Raspberry Pi:

Now we can capture a Raspberry Pi screenshot from our computer with a much simpler command:

However, note that it leads to corrupted PNG files in my case, possibly because of different environment settings between the computer and the Raspberry Pi board. meaning YMMV.

Initiate Screenshoting from Raspberry Pi

If you don’t have a Linux computer, the method above will not work unless you use the Windows subsystem for Linux. Another way is to install an SSH server in Windows, and then run the following command inside Raspberry Pi:


That’s it. In case you’d like a method that automatically uploads a screenshot after you select an area with your mouse, have a look at upscrot Python script.

Share this:

Support CNX Software! Donate via cryptocurrencies or become a Patron on Patreon

ROCK Pi 4C Plus
Notify of
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
Weller PCB manufacturer