I want to install XQuartz on my Mac so that it has an X server, and then forward it to remote hosts that I SSH onto.
So that I can run GUI applications on remote hosts without local X server (or window manager). GUI apps on remote hosts will connect to the forwarded X server on my Mac, and display whatever window directly on my Mac.
First install XQuartz. For example, you may use homebrew by running
brew install xquartz.
launchctl load -w /Library/LaunchAgents/org.xquartz.startx.plist and then
reboot. (Instructed by this Reddit post.
Note that this step is necessary only if you want to start X-forwarded SSH session
from Terminal.app, vs. from XTerm in XQuartz. Anyway, this step is highly recommended.)
Now, if you fire up Terminal.app, variable
$DISPLAY should be set. Actually,
it points to the X server in XQuartz.
~/.ssh/config, add the following attributes to whatever hosts for which you want
to enable X11 forwarding. It is not recommended to enable X11 forwarding for untrusted
remote hosts, just like you should not forward your SSH agent to untrusted remote
ForwardX11 yes ForwardX11Trusted yes ServerAliveInterval 60 ForwardX11Timeout 596h
First, make sure
xauth is installed. Then make sure the following items are
sshd configuration (usually at
AllowTcpForwarding yes X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost yes
sshd. Now if you SSH onto a remote host for which you have enabled
X11 forwarding, variable
$DISPLAY should be set. Install
xterm and run it to
make sure forwarding works. You can now run whatever GUI app you like, such as