0

I have a macOS machine running Catalina.

I have also have a Linux machine, running Ubuntu 20.04.

I want to ssh from the Linux machine to the Mac by a command such as ssh -X user@macos-machine.

When I try to do this, I get the error message "X11 forwarding request failed on channel 0". The ssh itself works, as I get a shell running on the Mac and displaying on the Linux, but programs like xeyes and xterm give errors like "Can't open display:" (For reference, the DISPLAY variable does not get set.)

The xeyes and xterm executables exist on the macos machine, and they work if i use XQuartz.app. That is, if I am at the console of the macOS machine, xeyes and xterm work and display on the macOS machine.

My Linux machine can successfully run ssh -X to other Linux hosts, so I think I have to do something to the macOS host.

None of the machines has X11Forward turned on (or off) explicitly in /etc/ssh/ssh_config and I would like to avoid directly editing files in /etc if some other, more macOS -like, solution exists.

1
  • XQuartz is not needed for this (and it is not involved even had it been installed).
    – jksoegaard
    Jul 9, 2023 at 22:14

1 Answer 1

1

You will need to turn on X11 forwarding in the settings for the SSH daemon on the Mac.

In order to do that, you need to edit the file /etc/ssh/sshd_config (note: this is a different file than the ssh_config you've mentioned in your question). Insert the following lines:

X11Forwarding yes
X11UseLocalhost no

And then restart sshd and you should be able to use ssh -X like you want.

There's no "more macOS-like" solution for than editing the file and restarting the daemon - like you would on Linux.

1
  • Awesome, thank you so much @jksoegaard It worked exactly as you say, except that i didn't have to restart the daemon. (Per 1488060 each new incoming connection gets a new process, which i suppose rereads the file.) This works, and i can run xterm and xeyes, and we'll see what else. For reference, DISPLAY is set to localhost:10.0
    – dan
    Jul 10, 2023 at 3:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .