-
Install
Xquartz
to get X11 support on MacOS. You can googleXquartz
and download it from its official site, or install using HomeBrew.brew cask install xquartz
-
Launch
Xquartz
. Go toPreference
->Security
, click the boxAllow connections from clients
. NOTE: You have to lauchXquartz
withAllow connections from clients
enable everytime you want tossh
to remote server with X11 forwarding support. -
Lauch
terminal
oriterm
. Add environmentDISPLAY
.# to add an environment entry only working on current terminal, use `export` export DISPLAY=:0 # to add an environment entry working on every terminal, # append `export DISPLAY=:0` to `.bashrc` or `.zshrc` in case you use zsh.
-
Lauch
terminal
oriterm
, use flag-Y
instead of-X
withssh
.ssh -Y user@address
-
Why do I need to install
Xquartz
?From https://stackoverflow.com/a/50182736/6769366,
XQuartz is standard. It used to come bundled with the OS, but Apple removed it back around Mavericks.
-
Why do I have to add environment
DISPLAY
?Please see https://askubuntu.com/a/432257/745885.
-
Why do I have to use
-Y
instead of-X
?I got the following error when trying to run a python script which draws some curves using
matplotlib
:X Error of failed request: BadAccess (attempt to access private resource denied) Major opcode of failed request: 18 (X_ChangeProperty) Serial number of failed request: 12 Current serial number in output stream: 15
This problem is sovled when using
-Y
instead of-X
. Haven't got enough time to find exact explanation, just post a link for those who are curious: Can't run “ssh -X” on MacOS Sierra.