8

How to run on Mountain Lion X11 forwarding via SSH?

Example:

ssh -X some@example.com xterm

my /etc/sshd_config has

X11Forwarding yes
#X11DisplayOffset 10
X11UseLocalhost yes

# XAuthLocation added by XQuartz (http://xquartz.macosforge.org)
XAuthLocation /opt/X11/bin/xauth

Restarted sshd with

launchctl stop com.openssh.sshd
launchctl start com.openssh.sshd

(and from the Preferences -> Sharing too)

Started XQuatrz, and from the xterm I run

ssh -v -X mrp@192.168.1.17 xterm        #this part not works :)

got the next:

debug1: Authentication succeeded (keyboard-interactive).
Authenticated to 192.168.1.17 ([192.168.1.17]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Requesting X11 forwarding with authentication spoofing.
debug1: Sending command: xterm
debug1: Remote: No xauth program; cannot forward with spoofing.
X11 forwarding request failed on channel 0
xterm: Xt error: Can't open display: 
xterm: DISPLAY is not set
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2656, received 2480 bytes, in 0.1 seconds
Bytes per second: sent 29582.4, received 27622.1
debug1: Exit status 1

from the xterm

$ echo $DISPLAY
/tmp/launch-BHtJfJ/org.macosforge.xquartz:0

changing it to :0 doesn't helps

running from the xterm

$ xauth list
jonatan.local/unix:0  MIT-MAGIC-COOKIE-1  f4f85682af36ae7d95cd3d244cb6beb2
192.168.1.9:0  MIT-MAGIC-COOKIE-1  f4f85682af36ae7d95cd3d244cb6beb2
jonatan.local:0  MIT-MAGIC-COOKIE-1  f4f85682af36ae7d95cd3d244cb6beb2

Any idea?

2
  • Could you clarify what part isn't working for you?
    – demure
    May 24 '13 at 15:36
  • @demure My english is not enough good, i was in hope than the error meesage is enough clear. But ok, added an comment to the question, to show exactly what not works. Or more precise, not works the X-protocol tunneling via ssh for some strange reason. Maybe xauth. Thank you for interest. :)
    – jm666
    May 24 '13 at 20:03
8

You need to open XQuartz, go to X11PreferencesSecurity, there are two check boxes: disable the first, enable the second. Restart XQuartz and try again. You will also need to define the $DISPLAY variable like this:

export DISPLAY=clienthost:0.0
3
  • Meantime i discovered the problem was in the another side - not in my OS X. ; Thank you anyway +1.
    – jm666
    Oct 17 '13 at 16:34
  • @jm666, Andreu I have the same problem and this solution didnt work for me, #jm66 could you share your experience in solving this problem.
    – math137
    Dec 27 '14 at 1:58
  • What is clienthost?
    – Jonathan
    Sep 12 '16 at 23:49
1

Not sure how this could happen, but from the SSH source where the error message comes:

/* Try to open a socket for the local X server. */
display = getenv("DISPLAY");
if (!display) {
    error("DISPLAY not set.");
    return -1;
}

It indicates that indeed ssh thinks the variable is not set at all (i.e. not malformed or something, but missing).

I'm not sure if SSH does change the user context so it gets a different environment. You can try

ssh -vvv ....

(multiple "v") to get more debug output, maybe this gives a hint somewhere in startup.

2
  • wow - good idea the multiple vvv - going to check. Thanx :)
    – jm666
    May 24 '13 at 20:04
  • ok, hope it helps May 26 '13 at 10:23

You must log in to answer this question.

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