Skip to content

Instantly share code, notes, and snippets.

@ha7ilm
Last active August 19, 2021 19:51
Show Gist options
  • Save ha7ilm/c75204826f6bc5f7a740f9adb987e967 to your computer and use it in GitHub Desktop.
Save ha7ilm/c75204826f6bc5f7a740f9adb987e967 to your computer and use it in GitHub Desktop.
copying image from clipboard of remote machine to clipboard of local machine over SSH in Linux
#!/bin/sh
rm /tmp/cliprect.png
ssh [email protected] "DISPLAY=:0 xclip -selection clipboard -t image/png -o -" > /tmp/cliprect.png
if [ $? -eq 1 ]; then
    notify-send -t 10000 "failed getting png from remote machine"
else
    xclip -selection clipboard -t image/png -i /tmp/cliprect.png
fi

The image on the clipboard of the remote machine will be on the clipboard of yours, you can just directly paste it.

Available under MIT license. Only use after understanding all the commands. /tmp/cliprect.png will be deleted if the script is ran.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment