How can I view pictures via ssh

You haven't said what Operating System you are connecting from. If you are using a *nix running an X server, you can use ssh X forwarding. This will enable you to run graphical applications on the remote server and have them displayed on the local machine. For example:

ssh -Y user@server
eog pictures/foo.png

Assuming the server has eog installed, this should cause the image to be opened and displayed on your screen.

For future reference, when asking questions on this site it is a good idea to specify the system you are using because the correct answer will often depend on it.


if you are on OS X, using iTerm2, you can do imgcat and display the image right in the terminal.

https://www.iterm2.com/documentation-images.htmlenter image description here


I've tried a few of the methods listed by other answers on this page, and I've tried them on both Ubuntu 20 and MacOS Mojave (my machine is a dual-booted abomination). On both systems I found that using the -X flag with ssh and then eog works, but is a bit slow and clunky. X-forwarding can be fine if you're browsing through small directories, but can become completely unusable if the directory you're working in has large amounts of data.

The best method I've seen is sshfs. It's a piece of cake to set up and I've found it to be extremely flexible. Basically it mounts the remote file system as a local drive, allowing you to either view the remote files or transfer files between your local runtime and the remote host - much easier and more intuitive than scp (though scp is a useful skill to know).

Ubuntu

I'm not sure about previous versions, but Ubuntu 20.04 came with sshfs. If your version of Ubuntu doesn't have it, you can install it with

sudo apt install sshfs

To use it, you will need an empty directory. I have mine in my home directory and have named it sc. To set it up you run the command:

sshfs -o follow_symlinks <user>@<server address>:/~/ sc

Voila! When you use your file explorer or terminal to open sc you'll see the remote drive mounted.

MacOS

The steps are nearly the same as the ones for Linux/Ubuntu. The difference here is that MacOS doesn't come with sshfs installed, and sshfs also requires some dependencies that also aren't included in MacOS. So first, we install these dependencies with:

brew install osxfuse

Now we can install sshfs with:

brew install sshfs

Then to mount the remote drive you need to make a local empty directory - I call mine sc and it's located in my home directory. Then you mount the remote drive in the remote directory with

sshfs -o follow_symlinks <user>@<server address>:/~/ sc

When you open sc with your favorite file explorer (such as Finder on MacOS) you'll find the remote drive there, probably with the name OSXFUSE Volume 0...

Hope this helps!

Tags:

Ssh

Pictures