x11 Forwarding on macOS
Install xQuartz
If homebrew installed:
brew install --cask xquartz
Or install from XQuartz website
Restart the machine
Enable iglx
defaults write org.macosforge.xquartz.X11 enable_iglx -bool true
According to this discussion here, but might not be relevant
# 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:
printenv DISPLAY
# /private/tmp/com.apple.launchd.oyK9GxAmbh/org.macosforge.xquartz:0
SSH config
locate your config file, mine is at ~/.ssh/config
Host euler.ethz.ch
HostName euler.ethz.ch
User USERNAME
ForwardX11Trusted yes
ForwardX11 yes
# XAuthLocation /opt/X11/bin/xauth # not required
Connect & Debug
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