Remote Screen Sharing on macOS is actually just VNC on port 5900. It's insecure by default - intended for local network sharing. Here's how you enable it and share it via ssh:

  1. Turn on Screen Sharing on the Host (the computer you want to connect to)
  2. Edit ~/.ssh/config on the Guest (the computer you connect from) to forward ssh over 5900
    Host foobar foobar.local
        LocalForward 5900 localhost:5900
  3. Connect via ssh from the Guest to the host
    ssh foobar.local
  4. Open Finder on the Guest and hit Cmd ⌘ + K or select Go => Connect to Server
  5. Connect to localhost (where the ports are forwarded locally)

Also of interest:

My personal setup

I have mine set up to work locally or over the internet.

Here's my ~/.ssh/config (also includes a SOCKS5 proxy):

# Hostname aliases

Host foobar
    Hostname foobar.local

Host foobar.ip

# Host-specific config

Host foobar.ip foobar foobar.local
    User myusername
    # macOS Finder's built-in VNC Screen Sharing
    LocalForward 5900 localhost:5900
    # Socks Proxy
    DynamicForward 6789

By AJ ONeal

If you loved this and want more like it, sign up!

Did I make your day?
Buy me a coffeeBuy me a coffee  

(you can learn about the bigger picture I'm working towards on my patreon page )