How do I enable X-forwarding on OSX Lion? ssh works fine when when I log-in from OSX Lion to Lion or Lion to Ubuntu.

ssh -X (X-forwarding) works fine when I log-in from Lion to Ubuntu.

However, I can't seem to get ssh -X to work from Lion to Lion.

How do I enable X forwarding on OSX Lion so I can run x applications from a remote machine?
X11 forwarding is disabled per default for OS X SSH servers. Do the following on the remote machine:

sudo vi /etc/sshd_config


Search for the following line and remove the # sign at the beginning, change the no to yes, so that you end up with this:

X11Forwarding yes


Then write the file and quit vim by hitting ESC and typing :wq and hitting return.

Now restart the sshd process by typing:

killall -SIGHUP sshd


This will kill your ssh session, but after that you should be able to use ssh -X as usual. You may get warnings because of missing X authority files.