Linux X11 Forwarding Recipe

  1. Client:
    1. macOS:
      1. (First time) Install XQuartz:
        brew install --cask xquartz
      2. Start XQuartz:
        open -a XQuartz.app
  2. Server:
    1. Ubuntu:
      1. ssh normally into the server:
        ssh root@host
      2. Make sure X11 apps are installed:
        apt-get update && DEBIAN_FRONTEND=noninteractive TZ=${TZ:-UTC} apt-get -y install x11-apps
      3. Update the sshd config to allow remote X11:
        sed -i 's/.*X11Forwarding no/X11Forwarding yes/g' /etc/ssh/sshd_config && sed -i 's/.*X11UseLocalhost yes/X11UseLocalhost no/g' /etc/ssh/sshd_config
      4. Update the sshd runtime configuration:
        kill -HUP $(cat /var/run/sshd.pid)
      5. exit the ssh session
      6. ssh again with X11 forwarding:
        ssh -Y root@host
      7. Test some X11 app
        xclock