Mac OSX Mavericks X11 “connection refused”

osx-mavericksx11-forwarding

Summary

I can SSH into a remote Linux box from my macbook, when I am in an Ubuntu Virtual Machine on that macbook – but not from OSX. I seek guidance on how to get OSX to work with X11 forwarding and suspect this is an OSX Mavericks problem. It used to work on Mountain Lion before I upgraded, so I think I missed a step.

Note that this is not X11/XQuartz won't auto-launch after upgrading to OS X Mavericks? as I did a format and clean install of Mavericks

X11 SERVER – Ubuntu Desktop

# This is the /etc/ssh/sshd_config file, trimmed down

# Relevant lines:
X11Forwarding yes
X11UseLocalhost yes
X11DisplayOffset 10

# Maybe relevant:
RSAAuthentication no
PubkeyAuthentication yes
AuthorizedKeysFile  %h/.ssh/authorized_keys
PasswordAuthentication yes # I didn't want to copy the rsa key into ubuntu VM so I accessed the server by password authentication rather than by rsa key.
TCPKeepAlive yes

I can ssh into this machine no problems.

X11 CLIENT – OSX Mavericks (not working)

I installed XQuartz 2.7.5, not sure which version I had on OSX Mountain Lion.

# edited /etc/ssh_config to prevent timeout issues

ForwardX11Timeout 596h

In the .ssh/config file I have

Host remotegossamer
  User joe
  port 22
  Hostname 55.55.55.55 # (edited.. I use no-ip as I have a dynamic ip)
  ForwardX11 yes
  ForwardX11Trusted yes # This gets rid of the warning: "Warning: untrusted X11 forwarding setup failed: xauth key data not generated"

When I ssh in I get a warning

> ssh remotegossamer
Warning: No xauth data; using fake authentication data for X11 forwarding.
Welcome to Ubuntu 13.10 (GNU/Linux 3.11.0-15-generic x86_64)
...

When I attempt to open an X11 window it fails

joe@gossammer:~$ firefox&
[1] 12195
joe@gossammer:~$ connect 127.0.0.1 port 6010: Connection refused

(process:12195): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
connect 127.0.0.1 port 6010: Connection refused
connect 127.0.0.1 port 6010: Connection refused
Error: cannot open display: localhost:10.0
^C
[1]+  Exit 1                  firefox

The Glib-CRITICAL is a firefox bug which is present for both ubuntu and osx clients, its the server's problem, and can be ignored.

The result of echo $DISPLAY is either localhost:10.0 or localhost:11.0 depending on whether I ssh in with the current machine first or second. Disconnecting both machines and sshing in in the reverse order has no effect; ubuntu client succeeds with 10 and 11, OSX fails with both.

I read up on this and port 6010 is correct as it starts at port 6000 and counts up in increments of 10, as mentioned in the server's sshd_config.

So I am baffled as to why OSX is not connecting…

I should note that when I used to ssh in from Mountain Lion, the XQuartz app would start – now it does not

X11 CLIENT – Ubuntu Desktop (In virtual machine on OSX Mavericks)

To configure the ubuntu VM to ssh into the server:

# I edited the /etc/ssh/ssh_config to have:
Host *
    ForwardAgent yes
    ForwardX11 yes
    ForwardX11Trusted yes

Then I ssh'd in with:

ssh -Y joe@55.55.55.55

and got no warnings. Then, I did:

> firefox&

And it opened in X11, great, so its a problem with OSX / the way I have set up OSX

And so

Did I miss something with setting up X11 on OSX Mavericks?

Best Answer

Try the following command (once you're logged in on OS X):

export XAUTHORITY=/home/your_name/.Xauthority

and then try some innocuous X app, like xeyes. If it works, you can put that statement in your .bashrc file.

Related Question