How to do X11 Forwarding on a Mac

This article describes X11 graphical forwarding over ssh which was used prior to the implementation of remote desktop apps.

Unless you are specifically learning about ssh and x11 forwarding for class, there are newer and easier methods of doing everything X11 was previously used to do.

Macs have not included a full version of SSH for almost a decade as of 2020 and due to MacOS Catalina and later requiring 64 bit apps, many easily installed work arounds no longer function.

Requirements

In order to do X11 Forwarding on Macs prior to MacOS 10.15.6 Catalina, you will need to make sure you have XQuartz installed.

XQuartz is available at https://www.xquartz.org/.


If you need to do X11 Forwarding on a Mac post MacOS 10.16/11.0 Big Sur or later, it is highly recommend you use some other application other than terminal such as iterm2

XQuartz can run on newer mac os like Big Sur but not from the pre-compiled installer without some modification. Information on their github and sourceforge repositories and how to modify the code is located in various spots on their website.

X11 can also be enabled by installing macports https://www.macports.org/ , configuring said software, then installing xorg-server

Note: macports is not ECI supported software, do not attempt to install and configure it unless you are confident in your abilities.

The default installation of xorg-server is not secure and will allow random people to remote into your computer without a password. Be sure to set a password, configure firewalls, and disable unneeded parts.

It is highly recommended you make a full backup of your computer before doing any work with macports as it can brick your system and the Apple recommended solution is to wipe and reinstall the operating system.

You have been warned.


How to connect

First, you will need to open up Terminal or an equivalent piece of software like iterm2 and you will want to type the following command:

ssh -Y <username>@csil.cs.ucsb.edu -o "XAuthLocation=/opt/X11/bin/xauth"

or

ssh -Y <username>@linux.engr.ucsb.edu -o "XAuthLocation=/opt/X11/bin/xauth"


This will connect you to the remote machine and allow you to run programs from that machine and display onto your computer screen.

Limitations

  • Since this is a remote connection, the windows being displayed will be slow due to your network connection, so please be patient with it.
  • X11 forwarding does not show the desktop of the remote computer.  You will need to call up the programs from the Terminal window.
  • X11 forwarding only works while the Terminal window connection is up.  DO NOT CLOSE OR QUIT TERMINAL during your session.