3

I have a linux machine which I am accessing via ssh with a MacBook. I wish to be able to view some .png files. I have run ssh with the -X option, edited ssh_config with these lines:

ForwardAgent yes ForwardX11 yes ForwardX11Trusted yes 

When I try running $display fileName.png I get the error

display: unable to open X server ' @ error/display.c/DisplayImageCommand/426. 

and if i run

$ DISPLAY=:0 display fileName.png 

then it acts as if something is running in the terminal but I can't view the image.

I've also tried opening it with eog fileName.png and get the error

Failed to connect to Mir: Failed to connect to server socket: No such file or directory Unable to init server: Could not connect: Connection refused 
4
  • 1
    It is unclear from the question as written, but you did edit ssh_config on the machine you want to connect to, and use ssh -X on the machine you want to connect from, right? And you restarted sshd after making the configuration changes? And you have X11 installed and open on the MacBook? Commented Nov 1, 2017 at 13:09
  • It's important to remember that the X11 forwarding is connecting the display only. The programs being run need to be installed on the remote machine. So, it's rather unlikely that eog fileName.png is going to work if you are ssh-ed into a Mac. Commented Nov 1, 2017 at 13:33
  • The linux is the remote machine and I am ssh-ing with my mac. Installed X11 and seems to be working now. Thanks! :) Commented Nov 1, 2017 at 13:34
  • Note: Moreover, the $DISPLAY you obtain using ssh -X is usually not :0 but a value incremented for each ssh -X connection, and starting with X11DisplayOffset (sshd_config, usually #X11DisplayOffset 10 ) Check it: echo $DISPLAY Commented Nov 1, 2017 at 18:06

2 Answers 2

7

You don't have xserver default installed on your OSX, so xclient has nothing to connect with.

"X11 is no longer included with Mac, but X11 server and client libraries are available from the XQuartz project." - https://support.apple.com/en-us/HT201341

3

The best way to view images in your terminal on a Mac is with iTerm + imgcat (part of it's shell utilities). You can actually install imgcat on the linux machine and then connect to it with ssh in an iTerm instance and it will display images just fine.

2
  • OMG, this actually works! To install on the server, use gist.github.com/wesbos/eac5f93478002312db1f (don't use the first command) Commented Sep 3, 2019 at 21:07
  • Note there's also pip install imgcat which supports options like --height which the non-Mac version of the above doesn't. Commented Sep 3, 2019 at 21:34

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.