How do I enable X-forwarding on OSX Lion?

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.