How can I open and view an image file via an SSH connection?

What I'm using

  • Ubuntu 14.04
  • SSH connection to another Ubuntu 14.04 machine

What I'm trying to do

  • View/Display the content of an image (.png, .jpeg, .bmp...) from the console.

I'm connecting to a VPS with Ubuntu and I need to know if an image file changes after I updated it, so I need to open/display the picture through ssh.

How can I do this?

1 Answer

If you want to use GUI applications with ssh, you need to use the -X or -Y options (use -Y):

 -X Enables X11 forwarding. This can also be specified on a per-host basis in a configuration file. X11 forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the user's X authorization database) can access the local X11 display through the forwarded connection. An attacker may then be able to perform activities such as keystroke monitoring. For this reason, X11 forwarding is subjected to X11 SECURITY extension restrictions by default. Please refer to the ssh -Y option and the ForwardX11Trusted directive in ssh_config(5) for more information. -Y Enables trusted X11 forwarding. Trusted X11 forwardings are not subjected to the X11 SECURITY extension controls.

So, for example, to use eog to display the remote image at /path/to/file.png, you would do

ssh -Y eog /path/to/file.png

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like