x11 Forwarding on macOS

Install xQuartz

If homebrew installed:

1
brew install --cask xquartz

Or install from XQuartz website

Restart the machine

Enable iglx

1
defaults write org.macosforge.xquartz.X11 enable_iglx -bool true

According to this discussion here, but might not be relevant

1
2
3
4
5
6
# check before writing
defaults read com.apple.x11 nolisten_tcp
defaults read org.X.x11 nolisten_tcp

defaults write com.apple.x11 nolisten_tcp -boolean false
defaults write org.X.x11 nolisten_tcp -boolean false

To validate:

1
2
printenv DISPLAY
# /private/tmp/com.apple.launchd.oyK9GxAmbh/org.macosforge.xquartz:0

SSH config

locate your config file, mine is at ~/.ssh/config

1
2
3
4
5
6
Host euler.ethz.ch                                                       
    HostName euler.ethz.ch                                                 
    User USERNAME                                                          
    ForwardX11Trusted yes                                                  
    ForwardX11 yes                                                         
#     XAuthLocation /opt/X11/bin/xauth # not required

Connect & Debug

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
ssh -Y USERNAME@euler.ethz.ch

# debug
ssh -v -Y USERNAME@euler.ethz.ch
# check for 
# debug1: Requesting X11 forwarding with authentication spoofing.

# validate
printenv DISPLAY
# localhost:10.0

display random.png
# show up in the XQuartz window

Note

Noted that this might conflict with some plotting software like R, matplotlib in python,

If so, one can switch to headless mode and view

This is my personal page, it does not in any way constitute official content of my employer or schools. The views and opinions expressed in individual's Web pages are strictly those of the page authors. Comments on the contents of those pages should be directed to the page authors.
Built with Hugo
Theme Stack designed by Jimmy